Paging in Gridview
In my开发者_StackOverflow gridview I have 6 pages. When I go to page two and try to sort by descending on any of my columns I get sent back to page 1. Is there a way to stay at page two?
You'll need to assign the current PageIndex
property of the GridView in your sorting method after the sort but before the DataBind.
In PageIndexChanging
event, you need to set the page and rebind your data. For instance like following:
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
bindGridView();//a method that re/sets the datasource
}
Check this article.
精彩评论