asp.netajaxgridviewpaginationupdatepanel

ASP.net Gridview Paging doesin't work inside UpdatePanel


Although, questions somehow similar to this have been asked for a number of times, but the question is still unsolved. Here is the question: I have a GridView which is contained in a tab container AJAX control which itself is inside an UpdatePanel. Gridview works excellent and its corresponding methods are fired accurately, but when I enable paging(e.g.) after I click on page 2, the GridView hides itself. here is my PageIndexChanging() method:

protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
    GridView1.PageIndex = e.NewPageIndex;        
    GridView1.DataBind();
    UpdatePanel2.Update();        
}

Why paging causes GridView to stop working correctly? What can I do?


Solution

  • The solution is that you should refill the dataset which is used to populate the gridview, each time your page index is changed. By this way, you could ensure that in each seperate postback which has been triggered by the gridview page number, results will be populated.