Roshan Roshan - 1 year ago 160
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.

Answer Source

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;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download