[英]how to add checkbox column to gridview
How to add checkbox column to gridview . 如何将复选框列添加到gridview。
i've tried: 我试过了:
foreach (GridViewRow objRow in GridView1.Rows)
{
TableCell tcCheckCell = new TableCell();
CheckBox chkCheckBox = new CheckBox();
tcCheckCell.Controls.Add(chkCheckBox);
objRow.Cells.Add( tcCheckCell);
}
How can i add the objrow
to gridview? 如何将objrow
添加到gridview? Or is there any other method of adding a checkbox column to an ASP.net GridView
? 或者是否有任何其他方法将复选框列添加到ASP.net GridView
?
The problem is that you cannot add a CheckBox
field to a GridView
in order to have a column of checkboxes - the GridView doesn't support it: 问题是你不能将一个CheckBox
字段添加到GridView
以便有一列复选框 - GridView不支持它:
Instead you have to change the template of each row, manually adding a CheckBox
control to the template of a row. 相反,您必须更改每行的模板 ,手动将CheckBox
控件添加到行的模板。
But it's what you have to do. 但这就是你必须要做的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.