GridView控件中的CheckBox [英] CheckBox in gridview control
问题描述
你好朋友,
我在asp.net的gridview ctrl上插入了复选框ctrl,
我需要从gridview中选择已选中复选框的行,
我的代码是:
foreach(GridView1.Rows中的GridViewRow行)
{
CheckBoxList cb =(CheckBoxList)row.Cells [0] .FindControl("cbl");
if(cb.Checked == true)
{
//即使选择了此复选框,也不会执行此行.
}
}
我的问题是如何找到已选中的复选框?
谢谢U,
U.Sankar
Hello Friends,
I Have insert checkbox ctrl on gridview ctrl in asp.net,
i need to select the row from gridview which checkbox is selected,
My code is:
foreach(GridViewRow row in GridView1.Rows )
{
CheckBoxList cb = (CheckBoxList )row.Cells [0].FindControl("cbl") ;
if(cb.Checked==true)
{
// this line is not executed even though i have selected the checkbox.
}
}
My Question is how to find whic checkbox is selected?
Thank U,
U.Sankar
推荐答案
foreach (GridViewRow row1 in GridView1.Rows)
{
CheckBox chk = (CheckBox)row1.FindControl("chkId");
if (chk.Checked)
{
String strTem = chk.ID;
}
}
您可以尝试.
you can try it.
这篇关于GridView控件中的CheckBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!