【发布时间】:2012-10-25 00:49:02
【问题描述】:
如何在 gridview 中获取我的复选框的复选框状态? 我已经像这样以编程方式添加它们,
foreach (GridViewRow gvr in GridView1.Rows)
{
tbCell = new TableCell();
cbGV = new CheckBox();
tbCell.Controls.Add(cbGV);
gvr.Cells.Add(tbCell);
{
通常,当它们位于项目模板中时,我会像这样(如下)获得复选框的状态,但这不起作用,所以有什么想法吗?
foreach (GridViewRow getRowItems in GridView1.Rows)
{
chkBox = (CheckBox)(getRowItems.Cells[0].FindControl("cbGV"));
if(chkBox.Checked == false)
{
chkBox.Checked = true;
}
}
【问题讨论】:
-
您尝试在哪个事件上获取复选框的值..
-
为什么不在模板中添加复选框?您正在混合网格和表格。
-
当我点击这个按钮时,
-
Amiram Korach:也许我会,但我需要知道我是否有解决方法,如果没有,或者需要很长时间才能实施,那么我可能会继续在 itemtemplate 中添加复选框
标签: c# asp.net gridview checkbox