Telerik RadCombobox fully supports binding to various types of Data Sources:
- DataTable, DataSet, DataView
- XmlDataSource
- SqlDataSource
- AccessDataSource
- ArrayList, Array
- ObjectDataSource
Data Sources can support both hierarchical and non hierarchical structures. However, Telerik RadComboBox DOES NOT support hierarchical binding.
 |
When the combobox is bound to such Data Sources, the combobox can only have one-level items. The combobox items CANNOT contain children. Therefore, Telerik RadComboBox does not support binding to SiteMapDataSource. |
The following properties and methods are related to data binding:
- DataSource - (mandatory) object. Set to an instance of your data source.
-
DataMember - (optional) string. If the
DataSource is a
DataSet and
DataMember is set, then Telerik RadComboBox assumes the
DataTable with the respective name in the
DataSet. Otherwise, the first
DataTable in the
DataSet is used.
- DataTextField - (optional). Gets or sets the field name from a data source to bind to the Text property.
-
DataValueField (optional) - Gets or sets the field name from a data source to bind to the
Value property.
-
DataBind() - (mandatory) method. Call this method after you have set the aforementioned properties per your scenario.
 |
If you need to map additional columns from the Data Source to properties of the respective combobox item, you have to hook on the ItemDataBound event. The event arguments passed to the event, e.Item and e.Item.DataItem, hold the instance of the combobox item being bound and the DataItem associated with the combobox item. You can then map a property from the DataItem to the property of the RadComboBoxItem class. You can then map a property from the DataItem (make sure to cast the DataItem object to your respective data type first - usually DataRowView) to the property of the RadComboBoxItem class. |
See live example at:
DataBinding