Gridview.Rows.count in multi page Gridview
I have a GridView tha开发者_如何学运维t the paging is true and I want to take the number of rows but only the number of rows to page 1 return,
Gridview.Rows.count
So you are looking for the total amount of rows on a specific page?
If so you shouldn't be trying to find that information from the GridView
but instead look at the underlying DataSource
that you bound your GridView
to.
Eg.
List<SomeObjects> lst = GetYourData();
yourGrid.DataSource = lst;
yourGrid.DataBind();
// if you want to get the count for a specific page
int currentPage = 2;
int countForPage2 = (lst.Count > currentPage * totalItemsPerPage)) ?
totalItemsPerPage : lst.Count - ((currentPage - 1) * totalItemsPerPage);
精彩评论