I'm using a RadComboBox and would like to get the selected item that was bound to the combobox instead of the selected value, index or text. I can do that with RadGrid but when I try to do it with a ComboBox the selected item's dataitem is always null.
RadGrid:
Event thisEvent = new Event(); thisEvent = (Event)e.Item.DataItem;
thisEvent is now the bound record of type Event.
RadComboBox:
List<BWGroup> individuals = new List<BWGroup>();individuals = _bwContext.BWGroups.Where(x => x.IsActive == true).OrderBy(x => x.BWGroupName).ToList(); IndividualsRadComboBox.DataTextField = "BWGroupName";IndividualsRadComboBox.DataValueField = "BWGroupID";IndividualsRadComboBox.DataSource = individuals; IndividualsRadComboBox.DataBind(); //After event is fired BWGroup group = new BWGroup(); group = IndividualsRadComboBox.SelectedItem.DataItem as BWGroup;
SelectedValue and SelectedIndex have the proper values but DataItem is always null so group is always null.
