简体   繁体   English

GridView具有大量数据的奇怪行为?

[英]GridView has strange behavior with large amounts of data?

I am creating a web report that uses a GridView with a SqlDataSource as the data source, and it is crashing for what seems to be large GridView s. 我正在创建一个Web报表,该报表使用带有SqlDataSourceGridView作为数据源,并且由于看起来很大的GridView而崩溃。 The web page allows the user to enter a date range, click a "Search" button, and then it does a SQL query based on the dates. 该网页允许用户输入日期范围,单击“搜索”按钮,然后根据日期进行SQL查询。 I know that the query works and that the dates are pulled correctly, but here is what's happening to cause the crash: 我知道查询有效且日期正确提取,但这是导致崩溃的原因:

  1. The user enters a large date range, and the "Search" button is clicked 用户输入一个较大的日期范围,然后单击“搜索”按钮
  2. The query runs, and correctly returns ~4500 entries 查询运行,并正确返回〜4500条目
  3. The user then enters a single day and clicks the "Search" button 然后,用户输入一天并单击“搜索”按钮
  4. Program crashes, giving this error message: 程序崩溃,显示以下错误消息:

    Description : An unhandled exception occurred during the execution of the current web request. 描述 :在执行当前Web请求期间发生未处理的异常。 Please review the stack trace for more information about the error and where it originated in the code. 请查看堆栈跟踪,以获取有关错误及其在代码中起源的更多信息。 Exception Details : System.InvalidOperationException: Operation is not valid due to the current state of the object. 异常详细信息 :System.InvalidOperationException:由于对象的当前状态,操作无效。

Looking at the stack trace and with a few breakpoints here and there, I'm pretty sure that this is happening before the OnClick method of the button is even called. 查看堆栈跟踪以及到处都有一些断点,我可以肯定这是在甚至调用按钮的OnClick方法之前发生的。 This has happened to me before on a similar report page that I made a month ago, but I would like to know why. 我以前在一个月前制作的类似报告页面上曾发生过这种情况,但我想知道为什么。

What is happening here? 这是怎么回事

I am executing this in debug mode on VS 2008, and I am coding in C# ASP.NET, if any of that makes a difference. 我在VS 2008上以调试模式执行此操作,并且在C#ASP.NET中进行编码(如果有区别的话)。 Also, I'm not sure what code would help, let me know if I need to edit and post some. 另外,我不确定会使用什么代码,请告诉我是否需要编辑和发布一些代码。

EDIT Here is the Stack Trace: 编辑这是堆栈跟踪:

[InvalidOperationException: Operation is not valid due to the current state of the object.] System.Web.HttpValueCollection.ThrowIfMaxHttpCollectionKeysExceeded() +2692462 System.Web.HttpValueCollection.FillFromEncodedBytes(Byte[] bytes, Encoding encoding) +61 System.Web.HttpRequest.FillInFormCollection() +148 [InvalidOperationException:由于对象的当前状态,操作无效。] System.Web.HttpValueCollection.ThrowIfMaxHttpCollectionKeysExceeded()+2692462 System.Web.HttpValueCollection.FillFromEncodedBytes(Byte []字节,编码编码)+61 System.Web。 HttpRequest.FillInFormCollection()+148

[HttpException (0x80004005): The URL-encoded form data is not valid.] System.Web.HttpRequest.FillInFormCollection() +206 System.Web.HttpRequest.get_Form() +68 System.Web.HttpRequest.get_HasForm() +8743895 System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull) +97 System.Web.UI.Page.DeterminePostBackMode() +63 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +133 [HttpException(0x80004005):URL编码的表单数据无效。] System.Web.HttpRequest.FillInFormCollection()+206 System.Web.HttpRequest.get_Form()+68 System.Web.HttpRequest.get_HasForm()+8743895 System.Web.UI.Page.GetCollectionBasedOnMethod(布尔dontReturnNull)+97 System.Web.UI.Page.DeterminePostBackMode()+63 System.Web.UI.Page.ProcessRequestMain(布尔includeStagesBeforeAsyncPoint,布尔includeStagesAfterAsyncPoint)+133

There you go, you have exceeded postdata limit . 到此为止您已经超出了postdata的限制 I believe you are posting back your entire grid to the server. 我相信您是将整个网格重新发布到服务器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM