Collection was modified; enumeration operation may not execute.的异常处理
在运行程序时遇到这样一段异常,仔细检查后发现是使用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.的异常处理的更多相关文章
- List使用Foreach 修改集合时,会报错的解决方案 (Error: Collection was modified; enumeration operation may not execute. ) - 摘自网络
当用foreach遍历Collection时,如果对Collection有Add或者Remove操作时,会发生以下运行时错误: "Collection was modified; enume ...
- 解决Collection was modified; enumeration operation may not execute异常
今天在使用foreach循环遍历list集合时,出现Collection was modified; enumeration operation may not execute.这个错误,查了半天才发 ...
- C# Collection was modified;enumeration operation may not execute
一.问题描述 在做 数组.列表.集合遍历时,可能我们会遇见这个问题.Collection was modified;enumeration operation may not execute ,翻译的 ...
- Error: Collection was modified; enumeration operation may not execute.
http://blog.csdn.net/ffeiffei/article/details/6131254
- Collection was modified; enumeration operation may not execute Dictionary 集合已修改;可能无法执行枚举操作
public void ForeachDic() { Dictionary dic = new Dictionary(); dic.Add("1", 10); dic.Add(&q ...
- 关于struts2的checkboxlist、select等标签发生could not be resolved as a collection/array/map/enumeration/iterator type异常的记录
1 刚进入该界面的时候发生错误,原因是 list="roles"中的这个集合是空的,导致错误 解决办法很简单,不能让list为空 2 刚进入该界面的时候list是有数据的,当点击提 ...
- Result Maps collection does not contain value for java.lang.Integer异常处理
使用Mybatis的时候出现这个问题是因为配置文件的问题造成的,mybatis需要写大量的配置文件, 尽管有mybatis-generator,但是里面的内容有很多还是要自己去写的,在这过程中难免会出 ...
- 做WP程序时遇到的一些问题及解决方法
问题1:Type 'JDBYSJ.Data.NewsChannel' cannot be serialized. Consider marking it with the DataContractAt ...
- C# 使用Linq递归查询数据库遇到的问题及解决方法
User表通常是我们在写"XX管理系统"项目时必须要用到的,有的情况下人员的分类属于树形结构,就是除了最高层和最低层,中间层都有相对的父和子,设计数据库的时候,我们通常会加一个pa ...
随机推荐
- PHP/HTML混写的四种方式总结
PHP/HTML混写的四种方式总结 一.总结 一句话总结: 注意点: 1.双引号里面解析变量:echo "$Content" 2.HEREDOC和NOWDOC的关系:类似于双引号包 ...
- IT增值服务实践心得体会:企业客户的钱比个人客户好赚得多
友情提示 本人喜欢直言不讳,不喜欢拐弯抹角.喜欢从客观和主观.自身和他人等多种角度去探讨问题.如有不当之处,欢迎吐槽. 若干心得体会1.企业客户的钱更好赚,个人客户的钱很难. 为什么这么说呢? a. ...
- jar命令+7z:创建,替换,修改,删除Jar, war, ear包中的文件
虽然现在已经有各种智能的IDE可以为我们生成jar包,war包,ear包,甚至带上了自动替换,部署的功能.但一定会有那么些时候,你需要修改或是替换jar包,war包,ear包中的某个文件而不是整个重新 ...
- 社会化登录分享-Android SDK的二次封装和使用
本系列文章将第三方的登录分享功能进行二次封装,统一接口调用,简化了接不同平台登录分享的步骤. 0 系列文章 系列一 Android SDK的二次封装和使用 系列二 源码解析 系列三 微信SDK接入 系 ...
- SpringMVC“Ambiguous mapping found. Cannot map 'XXXController' bean method”解决方法
[转 :http://www.fanfanyu.cn/news/staticpagefile/2351.html] 最近在开发项目的过程中SpringMVC抛了个"Ambiguous map ...
- 【t012】整理书架
Time Limit: 1 second Memory Limit: 32 MB [问题描述] 小明是一个非常喜欢读书的孩子,他有一个特别的书架,书架上摆放着他买的新书.当他决定要阅读某本图书时,他就 ...
- Dojo第一节:学会使用firebug对js,Dojo进行调适
内容概要: 学会使用firebug的基本功能 1. 简介:Firebug是Firefox的一个插件,用来对js代码进行调适的工具. (官方废话:Firebug是firefox下的一个插件,可以调试全部 ...
- Clustering Devices In An Internet Of Things
Clustering devices in an Internet of Things ('IoT'), including: receiving, by a device clustering mo ...
- 我已经写了DAL层的代码生成器
(1)创建您自己的解决方案 文件夹结构如以下: (2)编写代码: (要使用数据库 建议创建随意数据库就可以) 创建配置文件App.config代码例如以下: <?xml version=&quo ...
- Leetcode 136 Single Number 亦或
题意就是从一堆数中找出唯一的一个只存在一个的数.除了那个数,其他的数都是两个相同的数. 通过亦或的性质: 1)a^a = 0 0^a = a 2)交换律 a^b = b^ a 3)结合律 (a^b)^ ...