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

Selected item in a RadComboBox in editform

1 Answer 117 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andy Green
Top achievements
Rank 2
Andy Green asked on 02 Apr 2009, 01:51 PM
Hi

I've a RadComboBox in a Gridview Editform. It is filled from a dataclass in the code behind. When I go to edit mode, how do I set the selected value to that in the database.

Andy

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 03 Apr 2009, 04:56 AM
Hello Andy,

 If you are using a custom EditForm with a RadComboBox in it then you can either set the selected index of the combobox as shown below:
aspx:
<FormTemplate> 
      <telerik:RadComboBox ID="RadComboBox1" runat="server"
      </telerik:RadComboBox> 
</FormTemplate> 

c#:
 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridEditFormItem && e.Item.IsInEditMode) 
        { 
            GridEditFormItem editFormItem = (GridEditFormItem)e.Item; 
            RadComboBox combo = (RadComboBox)editFormItem.FindControl("RadComboBox1"); 
            combo.DataSourceID = "SqlDataSource1"
            combo.DataTextField = "ContactName"
            combo.SelectedIndex = e.Item.ItemIndex; 
        } 
    } 

Thanks
Princy.
Tags
Grid
Asked by
Andy Green
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Share this question
or