DataGrid如何实现checkbox控件的判断?就是判断每行的checkbox控件是否被checked了,请问如何做?
解决方案 »
- 在winFrom里面如何让制作一个抖动窗口
- 请问,c# 中有没有类似于InternetOpen之类的函数,我要通过http验证。
- c#中,多combobox控件绑定问题
- 请问:用C#在文本文档提取写入数据库里对应的字段
- C# 跨窗体传值问题!
- 如何让我自定义的类,对外人来说是不可以访问的?
- C++非托管与C#混合编程的问题
- 求计算机方面论文。
- 关于C#,菜鸟求助
- 子窗口如何最大化?? 急切!
- 如何在DataGrid(Windows Form)的表格中加入ComboBox控件
- 开源:.NET绘制打印网格线、单元格文本,各种网格如DataGrid打印、DataTable、HtmlTable等二维形式全搞定
{
CheckBox check = (CheckBox)item.FindControl("CheckBoxName");
if(check.Checked)
{
.....
}
http://community.csdn.net/Expert/topic/4271/4271124.xml?temp=.9170191
我想在页面下面放一个按钮,点击这个按钮,判断datagrid中所有checkbox被选中的行进行处理,请问我该如何做,原先写的代码
private void Button2_Click(object sender, System.EventArgs e)
{
string ID="";
string birthdaynotice="";
int num=0-int.Parse(TextBox1.Text);
foreach(DataGridItem item in dgInferEngineInfo.Items)
{
CheckBox check = (CheckBox)item.FindControl("cb");
if(check.Checked)
{
ID=item.Cells[0].Text;
birthdaynotice=DateTime.Parse(item.Cells[1].Text).AddDays(num).ToShortDateString();
string strSql = "update clubmember set " +
"birthdaynotice='"+birthdaynotice+
"' where ID="+ID;
ExecuteSql(strSql); LoadGrid();
}
}
}结果运行的时候出现错误集合已修改;枚举操作可能不会执行!!!
{
DataGridItem item = dgInferEngineInfo.Items[index]; ...
};foreach得到的枚举是只读的。枚举过程中不允许操作集合