1

I am using a Telerik RadGrid, and we're trying to get it to work with CustomPaging. I feel like I'm close, but it's not updating the data on the web client.

My aspx page code looks like this:

<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
</telerik:RadAjaxLoadingPanel>

<telerik:RadAjaxPanel ID="RadAjaxPanel2" runat="server" LoadingPanelID="RadAjaxLoadingPanel1">
    <telerik:RadGrid ID="rgItemCustomFields" runat="server" OnNeedDataSource="rgItemCustomFields_NeedDataSource" AllowPaging="true" AllowCustomPaging="true" VirtualItemCount="1000" >
        <PagerStyle Mode="NextPrevAndNumeric" Position="TopAndBottom"></PagerStyle>
    </telerik:RadGrid>
</telerik:RadAjaxPanel>

and my codebehind looks like this:

protected void Page_PreRender(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
    {
        rgItemCustomFields.Rebind();
    }
}

protected void rgItemCustomFields_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
    int currentPage = rgItemCustomFields.CurrentPageIndex;
    DataTable data = GetData(currentPage);

    rgItemCustomFields.DataSource = data;
}

The page displays on the screen, and I see the first 10 rows of data, and I'm on page 1. If I then click on a different page number, the grid disappears, preparing to display the new data, and the rgItemCustomFields_NeedDataSource method is called.

When I add a breakpoint and view the data in the rgItemCustomFields_NeedDataSource method it looks right: I see 10 rows, and they're different than what I have displayed on the screen.

I press continue in VS, the grid is redisplayed in the browser, but I'm back on page 1, and the original data is back.

Caching somehow? (I don't see how, but something is wrong.) Am I doing something silly?

(I know that VirtualItemCount is wrong: it's just hardcoded to 1000 right now while I try to get the rest of the stuff working. Also, once I allow different numbers of rows per page, the code will have to change; again, this is just simplified code while I try to get things working. I don't think that these things are part of the problem, but feel free to correct me if I'm being an idiot.)

Beska
  • 12,445
  • 14
  • 77
  • 112

1 Answers1

0

Have you tried the logic from this demo http://demos.telerik.com/aspnet-ajax/grid/examples/functionality/paging/custom-paging/defaultcs.aspx

rdmptn
  • 5,413
  • 1
  • 16
  • 29