I am attempting to fill a drop down list (from a database) once I choose a value from another drop down list. For instance the first drop down list is named ddlYear. When I select the year I want the next list to fill with all the makes from that year. Here is the code I have so far.
After I select the year nothing at all happens. What am I doing wrong?VB Code:
Protected Sub ddlYear_SelectedIndexChanged( _ ByVal sender As Object, _ ByVal e As System.EventArgs) Handles ddlYear.SelectedIndexChanged If IsPostBack = True Then Dim cnn As New OleDbConnection(obConn) Dim cmd As New OleDbCommand cmd = cnn.CreateCommand cmd.Connection = cnn Dim da As New OleDbDataAdapter Dim dsMake As New DataSet Try cnn.Open() cmd.CommandText = "Select Make From tblRecall Where Year = '" & _ ddlYear.Text & "'" da.SelectCommand = cmd da.Fill(dsMake, "Makes") ddlMake.DataSource = dsMake.Tables("Makes") ddlMake.DataMember = ("Makes") Catch ex As Exception WriteLine(ex.Message) Finally cnn.Close() da.Dispose() End Try End If End Sub




Reply With Quote