This is a migrated thread and some comments may be shown as answers.

Getting total number of rows in a grid

1 Answer 99 Views
Grid
This is a migrated thread and some comments may be shown as answers.
nickJr
Top achievements
Rank 1
nickJr asked on 27 May 2009, 08:46 PM
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

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 28 May 2009, 05:33 AM
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.
Tags
Grid
Asked by
nickJr
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or