Wednesday, March 21, 2012

Populating a dropdown box

Hi all,

I have populated one dropdown menu using data from a database using the following code

Sub Page_Load (seander as Object, e as EventArgs) Year.DataSource = GetYear() Year.DataBind()End Sub Function GetYear() As System.Data.SqlClient.SqlDataReader Dim connectionString As String = "server='localhost'; user id='sa'; password='eoyson'; Database='PupilRoll'" Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(connectionString) Dim queryString As String = "SELECT [Years].* FROM [Years]" Dim sqlCommand As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(queryString, sqlConnection) sqlConnection.Open Dim dataReader As System.Data.SqlClient.SqlDataReader = sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection) Return dataReader End Function
I am now trying to populate another dropdown list depending on the information selected from the previous dropdown list.
Cheers!

Try the tutorial right on this site:

Master Detail Filtering with Two Dropdownlists

0 comments:

Post a Comment