R – GridView paging always shows first page

ajaxasp.netgridview

I´m having a weird experience with paging on a GridView.
I´m trying to lazy load data into my griview by using an updatepanel with a timer and updateprogress attached to it.
So basicly what I´m trying to do is when the page with the grid loads I start the timer by enabling it. In the timer_tick event I´m fetching the data and load that into a variable. Then calling databind on the gridview forcing it to bind the data. Here I´m using a LinqDataSource to do that. Lastly I´m updating the UI via the Update method on the updatepanel.

This all works fine with sorting and filtering on the gridview but when I´m paging it the grid pages like it should but the paging template always stays on the first page (show 1 as active). Any ideas people? Here is some of my code:

    <asp:LinqDataSource runat="server" ID="OrdersDataSource" 
        OnSelecting="OrdersDataSource_Selecting" AutoPage="false" />

    <asp:GridView runat="server" ID="OrdersGridView" AutoGenerateColumns="false" 
        DataSourceID="OrdersDataSource"
        AllowPaging="true" AllowSorting="true" PageSize="3">

    <Columns>

<asp:Timer runat="server" ID="LazyLoadUpdatePanel" 
    Enabled="false"
    Interval="1" OnTick="LazyLoadUpdatePanel_Tick" />

protected void LazyLoadUpdatePanel_Tick(object sender, EventArgs e)
{
    if (datasource == null)
    {
        System.Threading.Thread.Sleep(2000);
        datasource = customer.Orders;
        OrdersGridView.DataBind();
        OrdersUpdatePanel.Update();

    }
    LazyLoadUpdatePanel.Enabled = false;
}

BTW I have tried with autopaging on the datasource and without it. That didn´t do the trick. As I said the paging seems to work, the UI just isn´t showing what it i supposed to.

Best Answer

EnableViewState="false" on the GridView made it work.

Related Topic