网格视图中的复选框控件 [英] check box control in the grid view
本文介绍了网格视图中的复选框控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何在按钮单击事件上的网格视图中获取选中的复选框的值
how can i fetch the values of checked check boxes in the grid view on a button click event
推荐答案
这是一篇不错的文章,涵盖了您的问题
在GridView控件中选择多个复选框 [ ^ ]
另一个 [
Here is a good article, which covers your issue
Selecting multiple checkboxes inside a GridView control[^]
another one[^]
Regards
Sebastian
Label1.Text = ((CheckBox)GridView1.SelectedRow.Cells[1].Controls[0]).Checked.ToString();
或
试试
or
try
protected void CheckBox_Checked(object sender, EventArgs e)
{
CheckBox chkbox = (CheckBox)sender;
GridViewRow r = (GridViewRow)chkbox.NamingContainer;
if(chkbox.Checked)
{
//You can update values by referring (r.FindControl("id of sth control") as SomeTypeControl).PublicProperty
}
}
您可以将值提取为
you can fetch values as
foreach(Gridviewrow gvr in Gridview1.Rows)
{
if(((CheckBox)gvr.FindControl("CheckBox1")).Checked == true)
{
int CustomerId = int.parse(gvr.Cells[2].Text);
}
}
这篇关于网格视图中的复选框控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文