在运行程序时遇到这样一段异常,仔细检查后发现是使用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);
} } }
}

  

Collection was modified; enumeration operation may not execute.的异常处理的更多相关文章

  1. List使用Foreach 修改集合时,会报错的解决方案 (Error: Collection was modified; enumeration operation may not execute. ) - 摘自网络

    当用foreach遍历Collection时,如果对Collection有Add或者Remove操作时,会发生以下运行时错误: "Collection was modified; enume ...

  2. 解决Collection was modified; enumeration operation may not execute异常

    今天在使用foreach循环遍历list集合时,出现Collection was modified; enumeration operation may not execute.这个错误,查了半天才发 ...

  3. C# Collection was modified;enumeration operation may not execute

    一.问题描述 在做 数组.列表.集合遍历时,可能我们会遇见这个问题.Collection was modified;enumeration operation may not execute ,翻译的 ...

  4. Error: Collection was modified; enumeration operation may not execute.

    http://blog.csdn.net/ffeiffei/article/details/6131254

  5. Collection was modified; enumeration operation may not execute Dictionary 集合已修改;可能无法执行枚举操作

    public void ForeachDic() { Dictionary dic = new Dictionary(); dic.Add("1", 10); dic.Add(&q ...

  6. 关于struts2的checkboxlist、select等标签发生could not be resolved as a collection/array/map/enumeration/iterator type异常的记录

    1 刚进入该界面的时候发生错误,原因是 list="roles"中的这个集合是空的,导致错误 解决办法很简单,不能让list为空 2 刚进入该界面的时候list是有数据的,当点击提 ...

  7. Result Maps collection does not contain value for java.lang.Integer异常处理

    使用Mybatis的时候出现这个问题是因为配置文件的问题造成的,mybatis需要写大量的配置文件, 尽管有mybatis-generator,但是里面的内容有很多还是要自己去写的,在这过程中难免会出 ...

  8. 做WP程序时遇到的一些问题及解决方法

    问题1:Type 'JDBYSJ.Data.NewsChannel' cannot be serialized. Consider marking it with the DataContractAt ...

  9. C# 使用Linq递归查询数据库遇到的问题及解决方法

    User表通常是我们在写"XX管理系统"项目时必须要用到的,有的情况下人员的分类属于树形结构,就是除了最高层和最低层,中间层都有相对的父和子,设计数据库的时候,我们通常会加一个pa ...

随机推荐

  1. 5.3.3.1 deque其他使用方式

    在本节里提供了一些关于deque其他使用方式. 提供相似UNIX中的命令tail的功能,显示一个文件最后面一段文本: def tail(filename, n=10): '返回文件最后的n行文本' w ...

  2. database software runInstaller无法看到全部的rac节点的处理方法

    近期遇到一个问题:rhel5.5下 安装11.2.0.4的rac.GI安装完了没问题. 可是 database software  runInstaller安装时,全部的节点在图形化界面中看不到. 搜 ...

  3. 与Qt的联系方式:邮件,论坛,销售,Bug报告

    If you want to learn more about upcoming things for Qt, please stay tuned for new blog posts and web ...

  4. 任务调度平台Cuckoo-Schedule

    任务调度平台Cuckoo-Schedule 1         概述 1.1      平台概述 Cuckoo-Schedule是基于Quartz-Schedule的轻量级任务调度框架,具有易学习.易 ...

  5. 语言的学习 —— 西班牙语(español)

    联合国六大官方语言:英语.法语.俄语.汉语.西班牙语.阿拉伯语: 在七大洲中,主要是在拉丁美洲国家中(巴西.伯利兹.法属圭亚那.海地等地除外).很多说西班牙语的人把他们的语言称为西班牙语(españo ...

  6. MapReduce 经典案例手机流量排序的分析

    在进行流量排序之前,先要明白排序是发生在map阶段,排序之后(排序结束后map阶段才会显示100%完成)才会到reduce阶段(事实上reduce也会排序),.此外排序之前要已经完成了手机流量的统计工 ...

  7. Android Studio如何打jar包

    前言 公司经常和客户提供SDK,提供一个jar包sdk是一件很平常的事.Eclipse 有图形界面和向导供开发者将一个项目导出为jar包,相对来讲是比较简单的,切换到Android Studio后,则 ...

  8. Video processing systems and methods

    BACKGROUND The present invention relates to video processing systems. Advances in imaging technology ...

  9. Scheme语言--简单介绍

    一年前事实上有时间看完SICP这本书,后来由于种种原因,一直没有继续再学.由于SICP中使用Scheme确实应用不多.在Java,C++的语言眼里,Scheme确实非常另类.现在MIT已经放弃了使用S ...

  10. 用决策树模型求解回归问题(regression tree)

    How do decision trees for regression work? 决策树模型既可以求解分类问题(对应的就是 classification tree),也即对应的目标值是类别型数据, ...