今天在操作gridview 自動新增行的時候,每行有約六十個字段,數據量提交比較大,到第16、17行的時候,就自動報錯“Operation is not valid due to the current state of the object.” ,經網上查詢,解決了這個問題。
以下爲轉載地址及文章:http://blog.csdn.net/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值根據需要可適當的修改。