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

On demand databind controls inside NestedTableView

1 Answer 49 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 20 Nov 2008, 04:31 PM
Hi,

I need to databind some controls inside a RadGrid's NestedTableView manually from codebehind. For performance
I woud like to do this only when the NestedTableView is opened. Is this possible? If yes, how?

Best regards,
Robert

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 21 Nov 2008, 07:18 AM
Hello Robert,

If your using NestedViewTemplate with some controls in it you can try out the following code to bind the controls with data on expanding the parent row in the grid.
aspx:
 <telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource2" runat="server" OnPreRender="RadGrid1_PreRender" > 
        <MasterTableView>         
         <NestedViewTemplate> 
       <telerik:RadGrid runat="server" DataSourceID="SqlDataSource1" ID="RadGrid3" AutoGenerateColumns="true">        
       </telerik:RadGrid> 
       </NestedViewTemplate>   

cs:
 protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
       foreach (GridDataItem item in RadGrid1.MasterTableView.Items) 
        { 
            if (item.Expanded) 
            { 
                foreach (GridNestedViewItem item1 in RadGrid2.MasterTableView.GetItems(GridItemType.NestedView)) 
                { 
                    RadGrid grid = (RadGrid)item1.FindControl("RadGrid3"); 
                    grid.DataSourceID = "SqlDataSource1"
                } 
            }            
        } 
    } 

Thanks
Princy.

Tags
Grid
Asked by
Robert
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or