I have what I think should be a straightforward question. I have a RadGrid with FormTemplate editing and AJAX enabled. One of the fields in the FormTemplate is a RadComboBox filled with U.S. State selections. I can bind the RadComboBox to the data source to populate all the items, but I'm not able to set the SelectedValue attribute.
This RadComboBox is loaded when the Edit button is clicked for a row on the RadGrid. A custom FormTemplate is used and the contents of the row being edited are loaded via AJAX.
If you are DataBinding, its literally as easy as adding
SelectedValue='<%# Bind("FieldName")%>'
Inside the FormTemplate declaration of the RadComboBox.
If you however want to programmatically determine what value to select, then you need to implement ItemDataBound in the RadGrid, like the following example:
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("yourControlName");
combo.SelectedValue= Somevalue;
}
}