Collection was modified; enumeration operation may not execute.的异常处理
2024-09-01 00:14:19
在运行程序时遇到这样一段异常,仔细检查后发现是使用Foreach...In语法体内运用了对Collection的Remove或Add导致的,只需要将foreach方法改为for方法即可。
for (int i = 0; i < this.prtdeallist.Items.Count; i++)
{
RepeaterItem repeaterItem = this.prtdeallist.Items[i]; if (repeaterItem.ItemType == ListItemType.Item || repeaterItem.ItemType == ListItemType.AlternatingItem)
{
HtmlInputCheckBox cbDealIsSelected = repeaterItem.FindControl("ckPpGuid") as HtmlInputCheckBox;
HiddenField hfDealGuid = repeaterItem.FindControl("HiddenField2") as HiddenField;
if (cbDealIsSelected.Checked )
{
DTDealItemWrapper DealItem = DTDealItemWrapper.FindById(hfDealGuid.Value);
DTDealWrapper DTdeal = null;
if (DealItem == null)
{
DTdeal = DTDealWrapper.FindById(hfDealGuid.Value);
}
if (DealItem != null)
{
DealItem.DDICRMReportStatus = false;
DTDealItemWrapper.Update(DealItem);
string LineCode = "LineCode:" + DealItem.DDILineCode;
RecordDeleteLog(hfDealGuid.Value, LineCode);
}
else if (DTdeal != null)
{
DTdeal.DDCRMReportStatus = false;
DTDealWrapper.Update(DTdeal);
string LineCode = "DD_NO:" + DTdeal.DDNo;
RecordDeleteLog(hfDealGuid.Value, LineCode);
} } }
}
最新文章
- 【.net 深呼吸】序列化中的“引用保留”
- Jquery知识点
- J2EE学习路线图
- 优雅的数组降维——Javascript中apply方法的妙用
- jquery的$().each,$.each的区别
- 2015多校.MZL&#39;s endless loop(欧拉回路的机智应用 || 构造)
- hdu 4521 小明系列问题——小明序列(线段树 or DP)
- linux概念之性能调优
- MapReduce shuffle阶段详解
- 转载:Source Insight查看ARM汇编源程序 &;&; 高亮显示程序 &;&; Source Insight打开project窗口出错
- C语言中的volatile
- CentOS7 开启关闭网卡
- Timus 1180. Stone Game 游戏题目
- 【Qt编程】基于Qt的词典开发系列<;六>;--界面美化设计
- 使用Python画玫瑰花
- javascript parseUrl函数解析url获取网址url参数
- tracert traceroute
- UI5-文档-4.2-Bootstrap
- Shell脚本之无限循环的两种方法
- 创建私有的cocoapod库