DataBind from Code-Behind

3 posts, 0 answers
  1. Charles
    Charles avatar
    4 posts
    Member since:
    Feb 2012

    Posted 27 Mar 2012 Link to this post

    I am replacing a standard listbox control with a RADLISTBOX control and thought it would be pretty seamless to switch out, but I am not having any luck with populating the RADLISTBOX. Can someone please tell me what I am doing wrong? I am not doing anything spectacular, just a simple databind with datareader.

    Here is my code aspx.vb

    Dim item As New RadListBoxItem()
            While reader4.Read
                item.Value = reader4("DescriptionLong")

    Here is my aspx. code

    <telerik:RadListBox ID="ConditionList" Width="160px" runat="server"
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 28 Mar 2012 Link to this post

    Hello Charles,

    RadListBox can be bound to a DataTable, DataSet and a DataView. Following is a sample code which create and fill the DataTable object, then bind it to the RadListBox.

    Protected Sub Page_Load(sender As Object, e As EventArgs)
        Dim str As [String] = System.Configuration.ConfigurationManager.ConnectionStrings("NorthwindConnectionString").ConnectionString
        Dim con As New SqlConnection(str)
        Dim command As [String] = "SELECT EmployeeID, FirstName FROM Employees"
        Dim ad As New SqlDataAdapter(command, con)
        Dim dt As New DataTable()
        ConditionList.DataTextField = "FirstName"
        ConditionList.DataValueField = "EmployeeID"
        ConditionList.DataSource = dt
    End Sub

    For more information please take a look into the following documentation.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Charles
    Charles avatar
    4 posts
    Member since:
    Feb 2012

    Posted 28 Mar 2012 Link to this post


    Thank you! that is exactly what I needed. Works like a champ!!

Back to Top