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

RadGrid with DropDown

1 Answer 79 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Terry
Top achievements
Rank 1
Terry asked on 17 Feb 2012, 05:53 PM
Hi there-

I want to detect if a DropDown field had an empty value before entering editmode but can't seem to tell how. What's happening is when I open inline editing for a item, the DropDown autoselect the first item in the datasource that the dropdown is bound to... even if previously there was no value in there. 

So for example I have no text values in this column:
 <telerik:GridDropDownColumn DataField="DataCenterCode" DataSourceID="SqlDataSource_DataCenters"
                            HeaderText="DataCenterCode" ListTextField="Acronym" ListValueField="Acronym"
                            UniqueName="DataCenterCode" ColumnEditorID="GridDropDownColumnEditor2">
                      </telerik:GridDropDownColumn>

But then once I enter edit mode, the first value is automatically selected. How can I determine if the value is actually empty for this field so that I can highlight it as requiring selection. Otherwise, it appears as though the first value was already selected.

Thanks for any help.

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 20 Feb 2012, 05:05 AM
Hello,

Try the following code.
C#:
protected void grid_ItemDataBound(object sender, GridItemEventArgs e)
{
 if (e.Item is GridEditableItem && e.Item.IsInEditMode)
 {
   GridEditableItem item = (GridEditableItem)e.Item;
   RadComboBox combo = (RadComboBox)item["GridDropDownColumn"].Controls[0];
   string value = combo.SelectedValue;
 }
}

Thanks,
Princy.
Tags
Grid
Asked by
Terry
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or