Roshan Roshan - 8 months ago 108
ASP.NET (C#) Question

Gridview Sorting and Paging not working on 2nd page

In ASP.NET gridview having 50 rows. I have set the Paging to 25. I am also using sorting. When I click the name, first page of sorting come in ascending, its working fine. When I click the second page of next 25 records,the sorting is not working. I need when I click the name of first page automatically next page of sorting should also work.


You have bind a gridview in PageIndexChanged method()

For example:

gv.AllowPaging = true;
gv.PageSize =10;
gv.PageIndexChanged+= new EventHandler(grid1_PageIndexChanging);

protected void grid1_PageIndexChanged(object sender, GridViewPageEventArgs e)
gv.PageIndex = e.NewPageIndex;