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

[Solved] Find number of items in RadGrid DetailTables

1 Answer 337 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dave Hollen
Top achievements
Rank 1
Dave Hollen asked on 19 Jan 2010, 09:28 PM
Hello,

I have a RadGrid that contains a DetailTable.  In the DetailTable, I wish to add ImageButtons that can change the order of the items in the DetailTable.

What I need to be able to determine is, how many records will be in the detail table.  I need to know this so that for Rows 2 through n-1 (where n is the number of items), I can show both the "Up" and "Down" buttons, and for row n, I can just display the "Up" button. 

How can I determine the number of records that will be in the detail table?  I have tried on DetailTableDataBind, ItemDataBound, etc. and so far nothing has worked.  Any suggestions?  Perhaps I need to use DetailTableDataBind or something I have already tried, but with different code?

Thanks!

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 20 Jan 2010, 06:42 AM
Hello Dave,

You can find the number of items in the child table in the PreRender event of the grid as shown below:
c#:
protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
        int count = RadGrid1.MasterTableView.Items.Count; 
        foreach (GridDataItem dataItem in RadGrid1.MasterTableView.Items) 
        { 
            if(dataItem.Expanded) // to avoid this condition check you can set MasterTableView>HierarchyLoadMode to Client 
            { 
                int count1 = dataItem.ChildItem.NestedTableViews[0].Items.Count; 
            } 
            
        } 
    } 

Thanks
Princy.
Tags
Grid
Asked by
Dave Hollen
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or