2011-03-19 20 views

回答

0

所以你正在尋找特定頁面上的總行數?

如果是這樣,您不應該試圖從GridView中找到該信息,而應該查看您綁定GridView的底層DataSource

例如,

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);