Getting total number of rows in a grid

2 posts, 0 answers
  1. nickJr
    nickJr avatar
    18 posts
    Member since:
    Jul 2007

    Posted 27 May 2009 Link to this post

    Hi,
    Can you tell me how to get the total number of rows in the grid? If I have enabled paging and each page displays 10 rows and if I have 4 pages I should get a count of over 30.
    How can I obtain this? Could you please let me know.

    Actually what I want is to get a list of DataKey values in all rows. Is there a way to itterate thru the list and get the DataKey values of all the rows, not just only the 10 rows displayed in the current page?

    thanks
    jay
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 28 May 2009 Link to this post

    Hello Jay,

    You can try out the following code to access the DataKeyValues on all pages in a grid on a button click:
    c#:
    protected void btnCount_Click(object sender, EventArgs e) 
        { 
            int count = RadGrid1.MasterTableView.PageCount; 
            int flag = 0; 
            for (int i = 0; i < count; i++) 
            { 
                RadGrid1.CurrentPageIndex = i; 
                RadGrid1.Rebind(); 
                foreach (GridDataItem dataItem in RadGrid1.Items) 
                { 
                    string strtxt = dataItem.GetDataKeyValue("ProductName").ToString(); 
                } 
     
            } 
            RadGrid1.CurrentPageIndex = 0; 
            RadGrid1.Rebind(); 
        } 

    Thanks
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top