grid view find last row when we do paging in c#.net

前提是你 提交于 2020-01-04 07:49:06

问题


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.


回答1:


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"]/pagesizewhich will give you total pages.

Now assign gridview.pageIndex=aboveresult




回答2:


You can also

int RowCount = GridView.Rows.Count;
GridView.PageIndex = RowCount/20;//as you set 20 rows per page...


来源:https://stackoverflow.com/questions/9079940/grid-view-find-last-row-when-we-do-paging-in-c-net

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!