I have a grid that uses a RADCombo for selection values in a row. When I select 'Edit' Ive put some code in the ItemCreated event that populates the dropdown from a custom object. This all works fine except that the dropdown list always shows the first item in the list. I need to pre-select the value in the dropdown that matches the value in the grid
eg in the grid column I have "80's"
the drop down has 2 values "70's" and "80's" and it always shows "70's" as the value when in fact is should be "80's"
How can I get the value from the cell to pre-select the value ?
Heres how im getting the drop down
eg in the grid column I have "80's"
the drop down has 2 values "70's" and "80's" and it always shows "70's" as the value when in fact is should be "80's"
How can I get the value from the cell to pre-select the value ?
Heres how im getting the drop down
protected void RadGridSecondaryCategories_ItemDataBound(object sender, GridItemEventArgs e) |
{ |
if (e.Item is GridEditableItem && e.Item.IsInEditMode) |
{ |
GridEditableItem _item = (GridEditableItem)e.Item; |
Telerik.Web.UI.RadComboBox cb = (Telerik.Web.UI.RadComboBox)_item["Category"].FindControl("RadComboBoxCategories"); |
cb.DataSource = categorymanager.Categories(this.RadComboBoxArtistGenre.SelectedValue, this.RadComboBoxType.SelectedValue); |
cb.DataTextField = "Category"; |
cb.DataValueField = "Category"; |
cb.DataBind(); |
//TO DO: |
//put code here to find the item in the dropdown from the database |
TableCell cell = _item["Category"]; |
int index = this.RadComboBoxCategories.FindItemIndexByValue();--- need to get the cell value and put it here |
cb.SelectedIndex = index; |
} |
} |