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?
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.
I just tried that above code. I had same issue and now it is working just fine.
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
GridView1.DataBind();
// UpdatePanel2.Update(); <-- Remove this line from your code.
}
I have GridView inside update panel. Did you write your event PageIndexChanging in your .aspx file also?
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With