populate a field based on a combobox on record Insert & Update

2 posts, 0 answers
  1. Shuja
    Shuja avatar
    7 posts
    Member since:
    Jan 2011

    Posted 18 Jan 2011 Link to this post


    I'm using a Rad Grid which has templated edit / insert forms.
    I want to select a value in a combobox for business unit name but when i save the record i want the "business unit name" to be the value of the combobox but i have another field called Business code which i would need to assign a value to based on the "business unit name" combobox value selected. How do i do this as i can't seem to find an "Item_Inserting" event the Rad Grid (only has ItemInserted but i need to assign the value before i insert). This also goes for the update of a record.

    Can anyone suggest how i can do this?


  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 19 Jan 2011 Link to this post


    You could access the control in ItemDataBound event of grid and set the SelectedItem accordingly. Access the editform and use FindControl() to access RadCombobBox placed in FormTemplate.

    A sample code you can find here:
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
        if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
            GridEditFormItem edititem = (GridEditFormItem)e.Item;
            RadComboBox combo1 = (RadComboBox)edititem.FindControl("RadComboBox 1"); // RadComboBox  placed in FormTemplate
            // select item in combo1

Back to Top