简体   繁体   中英

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

我有大约50000行gridview。并且我将pagesize设置为20网格view.so我们如何找到最后一行gridview.If我们下一步进行则需要更多时间。

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

You can also

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM