在Button的Click事件里怎么获取GridView中选中行的数据
怎么在Button的Click事件里怎么获取GridView中选中行的数据 --------------------编程问答-------------------- 循环 gridview --------------------编程问答--------------------for (int i = 0; i < rpProductManager.Items.Count; i++)--------------------编程问答-------------------- foreach(GridViewRow gr in gridview1.Rows)
{
CheckBox CB = (CheckBox)rpProductManager.Items[i].FindControl("single_Chk");
if (CB.Checked == true)
{
string delID = ((HiddenField)rpProductManager.Items[i].FindControl("delid")).Value;
sqlt.Operate("delete from plute_Product where proid='" + delID + "'");
}
}
{
TextBox txt=gr.FindControl("txt") as TextBox;
//gr.Cells[i].Text
} --------------------编程问答-------------------- gridview1.SelectedDataKey;//获得选中行的数据键值,返回DataKey
gridview1.SelectedIndex;//获得选中行的索引,返回int
gridview1.SelectedRow;//获得选中行的行,返回DataRow
gridview1.SelectedValue;//获得选中行的数据键值,返回object --------------------编程问答-------------------- 前提是,在GridView中有选中行 --------------------编程问答-------------------- 等待高人指点教育... --------------------编程问答--------------------
string sb=String.Empty;
for (int i = 0; i < GridView1.Rows.Count; i++)
{
CheckBox CB = (CheckBox)GridView1.Rows[i].FindControl("CheckBox1");
if (CB.Checked == true)
{
sb+=((Lable1)GridView1.Rows[i].FindControl("Lable1")).Text;//得到被选中的ID
}
}
--------------------编程问答-------------------- foreach (GridViewRow gvr in GridView1.Rows)
{
CheckBox chk = (CheckBox)gvr.FindControl("chkItem");
if (chk.Checked)
{
long longUID = long.Parse(gvDisplay.DataKeys[gvr.DataItemIndex].Value.ToString().Trim());
boolFlag = UsersBLL.Delete(longUID);
}
}
补充:.NET技术 , ASP.NET