Sys.WebForms.PageRequestManagerServerErrorException in ASP Grid
Problem:
Following exception occurs when bind the large amount of data.
ScriptResource.axd:885 Uncaught Error: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500(…)
Reason:
The cause of this issue is due to sending huge amount of data from the server.
Solution:
Please find the following solutions:
- For List collection of Data
Use ‘WebMethodAdaptor’ of DataManager for List collection data. Already we discussed about this in our knowledgebase. Please find the online link.
Serverside operations : https://www.syncfusion.com/kb/4300/server-side-api-for-datamanager-operations
Maxjson -length : https://www.syncfusion.com/kb/3063/script-error-throws-for-exceeding-maxjson-length-while-performing-serialization-or-deserialization
- For SQL Data binding
Bind datasource using SqlDataSource control and enable “EnableLoadOnDemand” property of Grid . Please find the code example.
ASPX
<asp:Content ID="ControlContent" runat="server" ContentPlaceHolderID="ControlsSection"> <div> <ej:Grid ID="FlatGrid" runat="server" DataSourceID="SqlData" EnableLoadOnDemand="true" AllowSorting="True" AllowPaging="True"> <Columns> <ej:Column Field="OrderID" HeaderText="Order ID" IsPrimaryKey="True" TextAlign="Right" Width="75" /> <ej:Column Field="Freight" HeaderText="Freight" TextAlign="Right" Width="75" Format="{0:C}" /> <ej:Column Field="ShipName" HeaderText="Ship Name" Width="110" /> <ej:Column Field="ShipCity" HeaderText="Ship City" Width="110" /> <ej:Column Field="ShipCountry" HeaderText="Ship Country" Width="110" /> </Columns> </ej:Grid> <asp:SqlDataSource ID="SqlData" runat="server" ConnectionString="<%$ ConnectionStrings:SQLConnectionString %>" SelectCommand="SELECT * FROM [Orders]"></asp:SqlDataSource> </div> </asp:Content>
’