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

RadGrid NestedViewTemplate Programatic Creation

1 Answer 64 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 1
Joe asked on 07 Jun 2012, 04:48 PM
Hello,

I am building a RadGridwith a NestedViewTemplate which essentially has a PlaceHolderControl and within that a RadGrid control.  So it looks like:

RadGrid-1 (with drop down menu for each MasterViewTemplate item)
|__PlaceHolder
     |__RadGrid-2
          |__Detail Table (if necessary; depends on Input A)
  |__Detail Table (if necessary; depends on Input A) 
  |__Detail Table (if necessary; depends on Input A) 

In RadGrid-1 there is a drop down menu input and based on this input the RadGrid-2 will have a varying number of details tables for each row.  In other words the RadGrid-2 can vary in size for each NestedViewItem of RadGrid-1 depending on the dropdown.

I have created RadGrid-1 and the PlaceHolder in my ASPX file.  Since the contents of RadGrid-2 depend on the data that exists in RadGrid-1 I have to wait for the data to be bound before I can begin creating my RadGrid-2's.  I decided that I would create the RadGrid-2's in the RadGrid1_PreRender events because this happens after the data is bound.

The problem that I am having is now when I traverse RadGrid1 to access all my RagGrid-2's (RadGrid-2 has some inputs fields) they can not be be found.  I am making a call like the following and coming up empty.

For Each masterViewItem As GridDataItem In RadGrid-1.MasterTableView.Items

	thisGrid = DirectCast(masterViewItem.ChildItem.NestedViewCell.FindControl("RadGrid-2"), RadGridThe problem that I am having is now when I traverse RadGrid1 to access all my RagGrid-2's they can not be be found.  I am making a call like:


I added the RadGrid-2's to the PlaceHolder Control in the PreRender event so why can I not see them after?  Please note that "RadGrid-1" and "RadGrid-2" are fake names and I am using real names in my scenario.

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 08 Jun 2012, 05:44 AM
Hello Joe,

Try accessing the second grid as shown below.
VB:
Protected Sub RadGrid1_PreRender(sender As Object, e As EventArgs)
    For Each item As GridNestedViewItem In RadGrid1.MasterTableView.GetItems(GridItemType.NestedView)
        Dim innergrid As RadGrid = DirectCast(item.FindControl("RadGrid2"), RadGrid)
    Next
End Sub

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