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

Declarative DataSources

ObjectDataSource

SqlDataSource

XmlDataSource

RadListBox can be bound to all ASP 2.0 and 3.5 DataSource types:

  • AccessDataSource
  • ObjectDataSource
  • XmlDataSource
  • SqlDataSource
  • SiteMapDataSource
  • LinqDataSource
  • EntityDataSource
  • OpenAccessDataSource

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

  • DefaultVB.aspx
  • DefaultVB.aspx.vb
  • listbox.xml
<%@ Page AutoEventWireup="true" Inherits="ListBox.Examples.PopulatingWithData.DeclarativeDataSources.DefaultVB"Language="vb" CodeFile="DefaultVB.aspx.vb"  %>

<%@ 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>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <div class="demo-containers">
        <div class="demo-container size-thin">
            <h2>ObjectDataSource</h2>
            <telerik:RadListBox RenderMode="Lightweight" ID="RadListBox1" runat="server" Height="200px" DataSourceID="ObjectDataSource1"
                DataTextField="Title" DataValueField="Id" Width="270px">
            </telerik:RadListBox>
            <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" TypeName="Telerik.Web.Examples.MovieSample"
                SelectMethod="GetMovieList"></asp:ObjectDataSource>
        </div>
        <div class="demo-container size-thin">
            <h2>SqlDataSource</h2>
            <telerik:RadListBox RenderMode="Lightweight" ID="RadListBox2" runat="server" Height="200px" DataSourceID="SqlDataSource1"
                DataTextField="ProductName" DataValueField="ProductID" Width="270px">
            </telerik:RadListBox>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
                ProviderName="System.Data.SqlClient" SelectCommand="SELECT [ProductID], [ProductName] FROM [Products] ORDER By ProductName">
            </asp:SqlDataSource>
        </div>
        <div class="demo-container size-thin">
            <h2>XmlDataSource</h2>
            <telerik:RadListBox RenderMode="Lightweight" ID="RadListBox3" runat="server" Height="200px" Sort="Ascending"
                DataTextField="Text" DataValueField="Value" Width="270px">
            </telerik:RadListBox>
            <asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/Listbox/Examples/PopulatingWithData/DeclarativeDataSources/listbox.xml">
            </asp:XmlDataSource>
        </div>
    </div>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance