• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 449
  • Last Modified:

How to know the pageindex of the last page of a gridview

Thanks. It looks simple.
1 Solution

You may have page size

and number of record


 Page size / number of record  = you will get how many paging page you have

and last pageindex =  -number of record - (pagesize * number of page )


maidinhtaiAuthor Commented:
Simply it's gridview1.PageCount-1. And I found the problem is at the Page_Load event and Page_SaveStateComplete event. gridview1.PageCount always returns 0 in Page_Load event and it returns a number >= 0 in Page_SaveStateComplete event. That's why I always get a error.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now