New to Telerik UI for ASP.NET AJAXStart a free 30-day trial

Binding to ASP DataSource components

RadComboBox supports binding to all ASP.NET DataSource components, including:

Databinding Properties

The following properties are used when binding RadComboBox to a data source

PropertyDescription
DataSourceIDSet to the ID of your data source. This is mandatory when binding RadComboBox declaratively.
DataSourceSet to an instance of your data source. This is mandatory when binding RadComboBox at runtime.
DataMemberSet the name of a specific Table in the data source. E.g. When binding the Combo to a DataSet object, this property will point to the respective DataTable object by the name.
DataTextFieldSet the name of the data source field to map it to Item's Text property.
DataValueFieldSet the name of the data source field to map it to Item's Value property.

Binding to AccessDataSource

Markup

ASP.NET
<telerik:RadComboBox ID="RadComboBox1" runat="server"
    DataSourceID="AccessDataSource1"
    DataTextField="Text"
    DataValueField="Value">
</telerik:RadComboBox>

<asp:AccessDataSource ID="AccessDataSource1" runat="server"
    DataFile="~/Data/Combo.mdb"
    SelectCommand="SELECT * FROM [Links]">
</asp:AccessDataSource>

Binding to LinqDataSource

Markup

ASP.NET
<telerik:RadComboBox ID="RadComboBox1" runat="server" 
    DataSourceID="LinqDataSource1" 
    DataTextField="ProductName" 
    DataValueField="ProductID">
</telerik:RadComboBox>

<asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="NorthwindEntities" TableName="Products">
</asp:LinqDataSource>

The LinqDataSource control in ASP.NET is compatible with Entity Framework versions up to EF 4.x.

Binding to ObjectDataSource

Markup

ASP.NET
<telerik:RadComboBox ID="RadComboBox1" runat="server"
    DataSourceID="ObjectDataSource1"
    DataTextField="Text"
    DataValueField="Value">
</telerik:RadComboBox>

<asp:ObjectDataSource runat="server" ID="ObjectDataSource1" 
    TypeName="CustomBusinessObject" 
    SelectMethod="GetItems">
</asp:ObjectDataSource>

CustomBusinessObject

C#
public class CustomBusinessObject
{
    public static List<ComboDataItem> GetItems()
    {
        List<ComboDataItem> itemsList = new List<ComboDataItem>();

        itemsList.Add(new ComboDataItem() { ID = 1, Text = "item 1" });
        itemsList.Add(new ComboDataItem() { ID = 2, Text = "item 2" });
        itemsList.Add(new ComboDataItem() { ID = 3, Text = "item 3" });

        return itemsList;
    }

    public class ComboDataItem
    {
        public string Text { get; set; }
        public int ID { get; set; }
    }
}

Binding to SiteMapDataSource

Markup

ASP.NET
<telerik:RadComboBox ID="RadComboBox1" runat="server"
    DataSourceID="SiteMapDataSource1"
    DataTextField="Title"
    DataValueField="Url">
</telerik:RadComboBox>

<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />

Binding to SqlDataSource

Markup

ASP.NET
<telerik:RadComboBox ID="RadComboBox1" runat="server"
    DataSourceID="SqlDataSource1"
    DataTextField="Text"
    DataValueField="Value">
</telerik:RadComboBox>

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
    ConnectionString="<%$ ConnectionStrings:ComboConnectionString %>"
    SelectCommand="SELECT * FROM [Links]">
</asp:SqlDataSource>

Binding to XmlDataSource

Markup

ASP.NET
<telerik:RadComboBox ID="RadComboBox1" runat="server"
    DataSourceID="XmlDataSource1"
    DataTextField="Text"
    DataValueField="Value">
</telerik:RadComboBox>

<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/ContentFile.xml">
</asp:XmlDataSource>

ContentFile.xml

XML
<items>
    <Item Text="New York" Value="1" />
    <Item Text="Paris" Value="2" />
    <Item Text="London" Value="3" />
</items>