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

[Solved] Related Combo Boxes as Edit Item Template in a Grid

1 Answer 74 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Suresh Mishra
Top achievements
Rank 1
Suresh Mishra asked on 21 Sep 2009, 07:05 PM
Hi,

I have a combobox in the edititemtemplate of two of my grid cloumns.  How can I relate the two, so that the second combo box gets refreshed everytime the value of the first combo box is changed?  Please note that both there columns are defined as edititems.  The edit mode for the MasterTableView is "inplace."

Your early reply will be greatly appreciated.

Thanks.

Suresh

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 22 Sep 2009, 05:33 AM
Hello Suresh,

You can try out the following code to populate a combobox based on the selection in another combobox in the grid:
aspx:
<telerik:GridTemplateColumn UniqueName="ContactTitle" HeaderText="ContactTitle">         
     <EditItemTemplate>  
         <telerik:RadComboBox ID="RadComboBox1" AutoPostBack="true" runat="server" SelectedValue='<%# Bind("ContactTitle") %>' DataSourceID="SqlDataSource1" DataTextField="ContactTitle"  OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged">             
         </telerik:RadComboBox>           
     </EditItemTemplate>  
</telerik:GridTemplateColumn>  
  
<telerik:GridTemplateColumn UniqueName="TemplateColumn">  
     <EditItemTemplate>  
         <telerik:RadComboBox ID="RadComboBox2"  runat="server">  
         </telerik:RadComboBox>  
     </EditItemTemplate>  
</telerik:GridTemplateColumn>  

c#:
 protected void RadComboBox1_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)  
    {  
        RadComboBox rdcbx = (RadComboBox)o;  
        GridEditableItem editedItem = rdcbx.NamingContainer as GridEditableItem;  
        RadComboBox ddList = editedItem.FindControl("RadComboBox2") as RadComboBox;  
        // change the data source for ddList here  
         .....         
    }  

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