当前位置: 代码迷 >> ASP.NET >> ★ 怎么在外部获得GridView当前行的DataKey
  详细解决方案

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

热度:9825   发布时间:2013-02-25 00:00:00.0
★ 如何在外部获得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());
}

}
  相关解决方案