Selected item in a RadComboBox in editform

2 posts, 0 answers
  1. Andy Green
    Andy Green avatar
    342 posts
    Member since:
    Aug 2008

    Posted 02 Apr 2009 Link to this post

    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
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 02 Apr 2009 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top