I have a GridView control which I fill thru c# code and want to do paging with code like this
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
BindGrid();
GridView1.PageIndex = e.NewPageIndex;
GridView1.SelectedIndex = -1;
}
The BindGrid() function is where I get the data source for the grid and bind it.
It all works nicely exept that I have to press twice in order for it to change pages.
What can I do so that it will page after one click?
Thank you.
Your binding order is not correct.. It should be like...
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
GridView1.SelectedIndex = -1;
BindGrid(); // Call bind here
}
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