CheckBoxList cbl = new CheckBoxList();
ListItem item = new ListItem("1", "1");
//在checkboxlist里添加一个listitem
cbl.Items.Add(item);
//添加listitem后,遍历checkboxlist的listitem,进行删除操作
foreach (ListItem i in cbl.Items)
{
cbl.Items.Remove(i);
}//foreach (ListItem i in cbl.Items)报错:集合已修改;可能无法执行枚举操作
解决方案 »
- Jquery的$.ajax怎么返回一个值?而不是回调函数!!
- WPF中如何控制TreeView滚动条有位置
- TextBox 的值变换时,触发客户端事件?
- 用dataset填充datagrid的问题
- FLASH,到底要怎么弄才好????????
- 请教高手....有关2003操作系统下验证控件引起按钮功能的问题,请教高手....
- 怎么让ASP页面自动关闭
- 请问作asp.net设计,都用什么工具呀,用visio吗?还是uml,如果uml设计的只是代码,没有界面呀
- 谁有nDOC1.3中文版本?
- 问一下asp.net starter kits是什么东西啊??
- |zyciis| System.Reflection.FieldInfo"发现字段进提供对元数据的访问权" 那如果这样的话.NET里面说只读的属性都可以赋值?
- QQ聊天室文本和图片显示
//这样删除就OK了
for(int i=0;i<cbl.Items.Count();i++)
{
cbl.Items.Remove(cbl.Items[i]);
i--;
}
然后循环该数组,REMOVE项。
The foreach statement is used to iterate through the collection to get the information that you want, but should not be used to change the contents of the collection to avoid unpredictable side effects.