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

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

1 Answer 68 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Shuja
Top achievements
Rank 1
Shuja asked on 18 Jan 2011, 05:03 PM
Hi,

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?

Regards,

Shuja

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 19 Jan 2011, 10:34 AM
Hello,


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
    }
}



-Shinu.
Tags
Ajax
Asked by
Shuja
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or