How to get to page1 when I refresh my gridview?
I have a gridview i开发者_高级运维n my webform.
In my search I got to page 4 for example, now I need to refresh the gridview and go to page 1.
How do I do that?
Upon the postback assign the GridView.PageIndex property to 0
mygridView.PageIndex = 0;
Have a look at MSDN http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.pageindex.aspx
You update a DataGrid
but changing the DataSource
, after this you need to call DataBind
on the GridView. And you can use SetPageIndex
to change page. Which will also trigger the OnPageIndexChanged
event.
Reset the PageIndex value
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.pageindex.aspx
精彩评论