Article: Create and populate Dropdown box dynamically using ASP.NET 2.0

Article Detail

Posted by:

 

Date:

Thursday, April 12, 2007 (CST)

 
Screen Shots



Article Brief Description

Create and populate Dropdown box dynamically using ASP.NET 2.0

Article Detail Description

This small demo program will tell how you can creat a dropdown box at run time and then bind it to the database.

 

Private Sub BindData()
        Dim mySource As SqlDataSource = New SqlDataSource(GetConnectionString, "SELECT * FROM Categories")
        Dim myList As DropDownList = New DropDownList
        myList.DataSource = mySource
        myList.DataTextField = "CategoryName"
        myList.DataValueField = "CategoryID"
        Panel1.Controls.Add(myList)
        Panel1.DataBind()
    End Sub

Average Rating:

Ferotech Solution Services Inc.