RadComboBox for ASP.NET AJAX

RadControls for ASP.NET AJAX

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

  • AccessDataSource

  • SqlDataSource

  • XmlDataSource

  • ObjectDataSource

  • SiteMapDataSource

  • LinqDataSource

To bind to a DataSource component, all you need to do is set the DataSourceID property of RadComboBox to the ID of the DataSource component. You should also set the DataTextField and DataValueField properties of RadComboBox to map the Text and Value properties of the items to the respective columns / fields from the data source.

If you need to map additional columns from the data source to properties of RadComboBox items, you can use the ItemDataBound event. The event arguments passed to the event, e.Item and e.Item.DataItem, hold the instance of RadComboBox item being bound and the DataItem to which it is bound. You can map a property from the DataItem to the corresponding property of RadComboBox item. Be sure to cast the DataItem object to the proper data type first.

AccessDataSource

CopyASPX
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/Data/Combo.mdb"
    SelectCommand="SELECT * FROM [Links]">
</asp:AccessDataSource>
<telerik:radcombobox 
    id="RadComboBox2" 
    runat="server" 
    datatextfield="Text" 
    datavaluefield="Value"
    datasourceid="AccessDataSource1" 
    onitemdatabound="RadComboBox2_ItemDataBound" />

SqlDataSource

CopyASPX
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ComboConnectionString %>"
    SelectCommand="SELECT * FROM [Links]"></asp:SqlDataSource>
<telerik:radcombobox 
    id="RadComboBox1" 
    runat="server" 
    datatextfield="Text" 
    datavaluefield="Value"
    datasourceid="SqlDataSource1" 
    onitemdatabound="RadComboBox1_ItemDataBound" />

XmlDataSource

CopyASPX
<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>

When using an XmlDataSource, the XML file should have the format shown below:

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

You can also load the XML file directly, rather than using a DataSource component as an intermediary.

ObjectDataSource

CopyASPX
<telerik:radcombobox 
    id="RadComboBox1" 
    runat="server"
    datavaluefield="ID" 
    datatextfield="Text"
    datasourceid="ObjectDataSource1">    
</telerik:radcombobox>
<asp:ObjectDataSource ID="ObjectDataSource1" TypeName="ComboObjectData" SelectMethod="GetItems"
    runat="server"></asp:ObjectDataSource>