New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Declarative DataSources

RadComboBox can be bound to all ASP 2.0 DataSource types:

  • AccessDataSource
  • ObjectDataSource
  • XmlDataSource
  • SqlDataSource
  • SiteMapDataSource
  • LinqDataSource

All you need to do is set the DataSourceID property of the ComboBox to the ID of the Data Source control. Also, you should set the DataTextField and DataValueField properties of the ComboBox to map the Text and Value properties of the Items to the respective columns/fields in the Data Source.

  • DefaultCS.aspx
  • DefaultCS.aspx.cs
  • styles.css
  • combobox.xml
<%@ Page Inherits="ComboBox.Examples.Functionality.DeclarativeDataSources.DefaultCS"Language="c#" CodeFile="DefaultCS.aspx.cs" AutoEventWireup="true"  %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
    <link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <div class="demo-container size-narrow">
        <telerik:RadComboBox RenderMode="Lightweight" ID="RadComboBox1" runat="server" Height="200px" Width="400" 
            Label="ObjectDataSource:" DataSourceID="ObjectDataSource1" DataTextField="Title"
            DataValueField="Id" />
    </div>
    <div class="demo-container size-narrow">
        <telerik:RadComboBox RenderMode="Lightweight" ID="RadComboBox2" runat="server" Height="200px" Width="400" 
            Label="SqlDataSource:" DataSourceID="SqlDataSource1" DataTextField="ProductName"
            DataValueField="ProductID" />
    </div>
    <div class="demo-container size-narrow">
        <telerik:RadComboBox RenderMode="Lightweight" ID="RadComboBox3" runat="server" Height="200px" Width="400" 
            Label="XmlDataSource:" Sort="Ascending" DataTextField="Text" DataValueField="Value" />

    </div>
    <div class="demo-container size-narrow">
        <telerik:RadComboBox RenderMode="Lightweight" runat="server" ID="RadComboBox4" DataTextField="ContactName" DataSourceID="EntityDataSource1"
            Height="200px" Width="400" Label="EntityDataSource:" >
        </telerik:RadComboBox>

    </div>

    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" TypeName="Telerik.Web.Examples.Movie"
        SelectMethod="GetMovieList" />

    <asp:SqlDataSource runat="server" ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
        ProviderName="System.Data.SqlClient" SelectCommand="SELECT [ProductID], [ProductName] FROM [Products] ORDER By ProductName" />

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

    <asp:EntityDataSource ID="EntityDataSource1" runat="server" ConnectionString="name=NorthwindReadWriteEntities"
        DefaultContainerName="NorthwindReadWriteEntities" EntitySetName="Customers" Select="it.[ContactName], it.[City], it.[ContactTitle]"
        AutoPage="true" OrderBy="it.[ContactName]">
    </asp:EntityDataSource>

    </form>
</body>
</html>

Support & Learning Resources

Find Assistance