Piush shukla
Piush shukla

Reputation: 165

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

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

Answers (2)

Mandar Jogalekar
Mandar Jogalekar

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

Now assign gridview.pageIndex=aboveresult

Upvotes: 1

rofans91
rofans91

Reputation: 3010

You can also

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

Upvotes: 0

Related Questions