Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gridview paging not working

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.

like image 659
Dov Miller Avatar asked May 16 '26 10:05

Dov Miller


1 Answers

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
} 
like image 127
Muhammad Akhtar Avatar answered May 18 '26 22:05

Muhammad Akhtar