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

Binding to DataTable, DataSet or DataView

RadListBox can be bound to a DataTable, DataSet and a DataView. This example shows binding to a DataTable object.

The declaration of the RadListBox object includes no DataSourceID property or section:

ASPNET
<telerik:radlistbox id="RadListBox1" runat="server"></telerik:radlistbox>

In the Page_Load event handler, create and fill the DataTable object, then bind it to the ListBox. You must call the DataBind method after setting the DataSource property.

C#
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        RadListBox1.DataSource = GetData(); 
        RadListBox1.DataTextField = "ProductName"; 
        RadListBox1.DataValueField = "ProductID"; 
        RadListBox1.DataBind();
    }
}
protected DataTable GetData()
{
    SqlDataAdapter adapter = new SqlDataAdapter("SELECT ProductID, ProductName FROM Products", ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString);
    DataTable result = new DataTable(); adapter.Fill(result);
    return result;
}			

See Also

In this article
See Also
Not finding the help you need?
Contact Support