首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

★ 怎么在外部获得GridView当前行的DataKey

2011-12-21 
★ 如何在外部获得GridView当前行的DataKey?以下事件是就是包含在GridView中Button的事件---protectedvoidB

★ 如何在外部获得GridView当前行的DataKey?
以下事件是就是包含在GridView中Button的事件
---
        protected   void   BtED_Click(object   sender,   EventArgs   e)
        {
              ‘怎样获得GridView当前行的DataKey?
        }

[解决办法]
可以在数据控件中的每行也就是Row中包含一个CheckBox控件;通过Foreach循环遍历每行,寻找此控件;如果此控件的Checked为True则根据此控件定位当前行,并获得当前行的DataKey!
[解决办法]
foreach(DataGridItem Item in dgList.Items)
{
if(((CheckBox)Item.FindControl( "checkthis ")).Checked)
{
DeleteRow(this.dgList.DataKeys[Item.ItemIndex].ToString());
}

}

热点排行