RadGrid paging error

Thread is closed for posting
5 posts, 0 answers
  1. Alan Smith
    Alan Smith avatar
    2 posts
    Member since:
    Mar 2010

    Posted 29 Mar 2010 Link to this post

    I am fairly new to C# .NET and very new to Telerik controls so please forgive me if this is trivial.

    I am having trouble getting the paging element to work for a RadGrid control.  Here is what I am doing: I read in a CVS file, parse it into a List<Dictionary<string,object>> and then add the data source to the RadGrid as such (omitting the code behind that creates the data).

                    var data = ReadInCSVData(csvData); 
                    var Idata = ConvertToIEnumerable(data); 
     
                    RadGrid1.DataSource = Idata.ToDataSource(); 
                    RadGrid1.DataBind(); 

    Now, this works as far as when the page comes up I get the initial grid populated with data.  However, when I try to perform any of the paging (i.e. select a page to go to, or click on next page) I get errors on the web page and the callbacks never happen.  I have break points in every function and none of them ever get called.  The error in the browser (script error) is:

    Sys.WebForms.PageRequestManagerServerErrorException: The state information is invalid for this page and might be corrupted.

    I have googled this error without being able to find a solution.  I have been trying to follow the examples from the telerik site.  Here is my ASPX page:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"  
        Inherits="BAPTFileUpload._Default" EnableEventValidation="false" ValidateRequest="false"%> 
     
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/tr/xhtml11/DTD/xhtml11.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml"
    <head></head
    <body> 
        <form runat="server" id="mainForm" method="post"
            <h2>Table below</h2> 
            <br /> 
            <telerik:RadScriptManager ID="RadScriptManager1" runat="server"  
                ondatabinding="Page_Load" /> 
            <!-- content start --> 
                <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
                    <AjaxSettings> 
                        <telerik:AjaxSetting AjaxControlID="RadGrid1"
                            <UpdatedControls> 
                                <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> 
                            </UpdatedControls> 
                        </telerik:AjaxSetting> 
                    </AjaxSettings> 
                </telerik:RadAjaxManager> 
                <telerik:RadGrid ID="RadGrid1" OnSortCommand="RadGrid1_SortCommand"  
                    OnPageIndexChanged="RadGrid1_PageIndexChanged" Width="97%" AllowSorting="True"  
                    PageSize="15" AllowPaging="True" AllowMultiRowSelection="True" runat="server"  
                    Gridlines="None"  
                onselectedindexchanged="RadGrid1_SelectedIndexChanged"
                    <MasterTableView Width="100%" Summary="RadGrid table" />     
                    <PagerStyle Mode="NextPrevAndNumeric" /> 
                </telerik:RadGrid> 
        </form> 
    </body> 
    </html> 
     





  2. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 30 Mar 2010 Link to this post

    Hello Alan,

    Instead of binding the grid conditionally using simple binding with DataBind() calls, you can transform your code to take advantage of the advanced binding with NeedDataSource handling. Thus you will be able to utilize features like paging, grouping, filtering, custom edit forms which are supported only with this type of binding or declarative data sources.

    Give this suggestion a try and let me know how it goes.

    Regards,
    Pavlina
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 30 Mar 2010 Link to this post

    Hello Alan,

    Additionally, I suggest you review to the following help articles, which elaborate on this matter:
    Known reasons for error messages
    Ajax, ViewState, and Firefox

    Regards,
    Pavlina
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  5. Alan Smith
    Alan Smith avatar
    2 posts
    Member since:
    Mar 2010

    Posted 01 Apr 2010 Link to this post

    Thank you for your reply, I appreciate your time.  However, maybe I am missing something.  I read the articles you posted and modified my code as such:
    Code Behind:
            protected void RadGrid1_NeedDataSource2(object source, GridNeedDataSourceEventArgs e) 
            { 
                CSVReader csvData = new CSVReader("c:\\usr\\local\\apache\\test2.csv"); 
     
                var data = ReadInCSVData(csvData); 
                var Idata = ConvertToIEnumerable(data); 
                this.data = Idata
     
                RadGrid1.DataSource = Idata.ToDataSource(); 
            } 

    ASPX
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"  
        Inherits="BAPTFileUpload._Default" EnableEventValidation="false" ValidateRequest="false"%> 
     
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/tr/xhtml11/DTD/xhtml11.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml"
    <head></head
    <body> 
        <form runat="server" id="mainForm" method="post"
            <h2>Table below</h2> 
            <br /> 
     
            <telerik:RadScriptManager ID="RadScriptManager1" runat="server"
                <Scripts> 
                    <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" /> 
                    <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" /> 
                </Scripts> 
            </telerik:RadScriptManager> 
            <!-- content start --> 
                <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
                    <AjaxSettings> 
                        <telerik:AjaxSetting AjaxControlID="RadGrid1"
                            <UpdatedControls> 
                                <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> 
                            </UpdatedControls> 
                        </telerik:AjaxSetting> 
                    </AjaxSettings> 
                </telerik:RadAjaxManager> 
                <telerik:RadGrid ID="RadGrid1"  
                    Width="97%" AllowSorting="True"  
                    PageSize="15" AllowPaging="True" AllowMultiRowSelection="True" runat="server"  
                    Gridlines="None"  
                    onneeddatasource="RadGrid1_NeedDataSource2"
                    <MasterTableView Width="100%" Summary="RadGrid table"  
                         />     
                    <PagerStyle Mode="NextPrevAndNumeric" /> 
                </telerik:RadGrid> 
        </form> 
    </body> 
    </html> 

    With this code I am having the same problem. 

    The second link that you posted (declarative data sources) shows an example of including a SQL data source right on the page.  While adding SQL data sources directly to the ASPX page seems to be the norm for certain types of applications, I get my data from a CSV file.  The file is read in and parsed into an enumerable Dictionary, so I do not have a SQL data source to add to the page. 

    Is the reason I am having these problems because I do not have a data source on the page (the examples on the main telerik site do not show data sources)?
  6. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 02 Apr 2010 Link to this post

    Hello Alan,

    I followed your scenario and prepared a simple runnable project which is working as expected. Give it a try and let me know if it helps to achieve the desired functionality.

    I hope this gets you started properly.

    Kind regards,
    Pavlina
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017