今天在操作gridview 自动新增行的时候,每行有约六十个字段,数据量提交比较大,到第16、17行的时候,就自动报错“Operation is not valid due to the current state of the object.” ,经网上查询,解决了这个问题。
以下为转载地址及文章:http://blog.youkuaiyun.com/dongxiaohui2008/article/details/8424082
异常信息: Operation is not valid due to the current state of the object.
错误源:System.Web
堆栈信息: at System.Web.HttpValueCollection.ThrowIfMaxHttpCollectionKeysExceeded()
at System.Web.HttpValueCollection.FillFromEncodedBytes(Byte[] bytes, Encoding encoding)
at System.Web.HttpRequest.FillInFormCollection()
分析异常信息:System.Web.HttpValueCollection.ThrowIfMaxHttpCollectionKeysExceeded():很有可能是在页面提交时,某个数据过大导致。
有个数据维护程序,最近一直报这个错误,以前一直OK,程序没做过变动,经研究发现原来是微软发布的一次更新引起的.在这次安全更新中对于asp.net单次的提交量做了一个最大量限制1000,出现这个异常正是因为页面提交量超过了1000这个限制.这个可以在web.config中增加参数来更改。
解决方法:
<appSettings>
<add key="aspnet:MaxHttpCollectionKeys" value="2000" />
</appSettings>
value值根据需要可适当的修改。
本文详细介绍了在使用GridView进行自动新增行操作时遇到的错误Operationisnotvalidduetothecurrentstateoftheobject.的解决方法。主要原因是页面提交量超过了ASP.NET的最大限制1000。通过在web.config中增加参数`aspnet:MaxHttpCollectionKeys`并调整其值,可以解决此问题。
2037

被折叠的 条评论
为什么被折叠?



