Reputation: 165
I have approximate 50000 row gridview.and i set the pagesize 20 grid view.so how we can find the last row gridview.If we do next then it takes more time.
Upvotes: 2
Views: 2403
Reputation: 3281
If I get your question right, you want to shift to last page from first page.
What you can do is when you are binding the gridview
save number of rows in your data source in viewstate
:
viewstate["rowCount"]=number;
Then use a seperate link for navigating to last page
which fires pageindexchanging event. On that event you can calculate Viewstate["rowCount"]/pagesize
which will give you total pages.
Now assign gridview.pageIndex=aboveresult
Upvotes: 1
Reputation: 3010
You can also
int RowCount = GridView.Rows.Count;
GridView.PageIndex = RowCount/20;//as you set 20 rows per page...
Upvotes: 0