2

I am trying to implement paging when reading from a huge database. When user moves to a page outside a window, i fetch the next set of records and populate the table for 9-10 pages. Problem is, after refreshing data source, i am not able to reset the PageIndex to 0, it is still on the last page after refresh. My code is as follows:

protected void AccountQueueGrid_PageIndexChanged(object sender, Telerik.Web.UI.GridPageChangedEventArgs e) 
{
int newWindowNumber = currentWindowNumber() + ( e.NewPageIndex / (windowSize / PageSize));
            if (newWindowNumber != currentWindowNumber())
            {
                PopulateAccountQueueGrid(newWindowNumber, true);
                AccountQueueGrid.CurrentPageIndex = 0;
                AccountQueueGrid.Rebind();

            }
}

PopulateAccountQueueGrid gets the new data and sets as DataSource and calls DataBind too. That part works fine. But setting CurrentPageIndex and then Rebinding doesnt reset it to 0. Have tried setting AccountQueueGrid.MasterTableView.CurrentPageIndex also, doesnt work.

AllowPaging and EnableViewState are set to true.

1 Answers1

0

Set your page index to 0 (zero) before binding the datasource below example perfectly worked for me.

AccountQueueGrid.CurrentPageIndex = 0;
AccountQueueGrid.DataSource = dsList.Tables[0];
AccountQueueGrid.Rebind();
Xpleria
  • 5,472
  • 5
  • 52
  • 66