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

dynamically fill radcombobox in radgrid column nested within formtemplate?

2 Answers 232 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jon-Jon Kershaw
Top achievements
Rank 2
Jon-Jon Kershaw asked on 16 Mar 2009, 07:12 PM
The question thread title explains it all.  How do you do this?

2 Answers, 1 is accepted

Sort by
0
Jon-Jon Kershaw
Top achievements
Rank 2
answered on 16 Mar 2009, 08:56 PM
sorry this radgrid is nested within another radgrid as well.

thanks.
0
Princy
Top achievements
Rank 2
answered on 18 Mar 2009, 03:38 AM
Hello,

I suppose that in your scenario the RadComboBox is placed in a TemplateColumn of a grid which is placed in the NestedViewTemplate of another grid which is inturn placed in the EditFormTemplate of the main grid. If thats the case, you can try out the following code to access the RadComboBox:
aspx:
 <EditFormSettings EditFormType="Template"
      <FormTemplate> 
          <telerik:RadGrid ID="EditRadGrid" DataSourceID="SqlDataSource1" runat="server" AutoGenerateColumns="true" > 
            <MasterTableView> 
            <NestedViewTemplate> 
              <telerik:RadGrid ID="NestedRadGrid" DataSourceID="SqlDataSource1" runat="server" AutoGenerateColumns="true" >             
                <MasterTableView> 
                 <Columns> 
                  <telerik:GridTemplateColumn UniqueName="Column"
                   <ItemTemplate> 
                    <telerik:RadComboBox ID="RadComboBox1" runat="server"
                    </telerik:RadComboBox> 
                   </ItemTemplate> 
                 </telerik:GridTemplateColumn> 
               </Columns> 
              </MasterTableView> 
            </telerik:RadGrid> 
          </NestedViewTemplate> 
          </MasterTableView> 
        </telerik:RadGrid> 
     </FormTemplate> 
 </EditFormSettings> 

cs:
 
 protected void RadGrid1_PreRender(object sender, EventArgs e)  
    {              
       foreach (GridEditFormItem editItem in RadGrid1.MasterTableView.GetItems(GridItemType.EditFormItem))  
        {  
            if (editItem.IsInEditMode)  
             {  
                RadGrid grid = (RadGrid)editItem.FindControl("EditRadGrid");  
                foreach (GridNestedViewItem item in grid.MasterTableView.GetItems(GridItemType.NestedView))  
                {  
                    RadGrid nestedgrid = (RadGrid)item.FindControl("NestedRadGrid");  
                    foreach (GridDataItem nestedDataItem in nestedgrid.MasterTableView.Items)  
                    {  
                        RadComboBox combobox = (RadComboBox)nestedDataItem["Column"].FindControl("RadComboBox1");  
                        combobox.DataSourceID = "SqlDataSource1"
                        combobox.DataTextField = "Category"
                        combobox.DataValueField = "Category"
                    }  
                }  
            }  
        }   
    }  

Thanks
Princy.
Tags
Grid
Asked by
Jon-Jon Kershaw
Top achievements
Rank 2
Answers by
Jon-Jon Kershaw
Top achievements
Rank 2
Princy
Top achievements
Rank 2
Share this question
or