Hi,
I have a mutiple DropDownList with label object in my web page. When I raise on 1st dropdown list event ,its working fine to show the correct result out on label. but when comes to 2nd dropdownlist and select a different value, nothing happens, even though I have a function wired up to the SelectedIndexChanged event. It still points to 1st dropdownlist value on the label( based on what i had clicked on 1st dropdownlist )
(note : different datasource but refer to same table in database)
Hope you guys can help!Thanks in advance!
I’ll try and post my code here as orderly as possible:
Protected Sub ddlVisualLocation_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles ddlVisualLocation.SelectedIndexChanged
Dim conString As String = ConfigurationManager.ConnectionStrings("prcConnectionString").ConnectionString
Dim MySql As New MySqlConnection(conString)
MySql.Open()
Dim cmd As New MySqlCommand("SELECT * from tbcomponentlocation WHERE Location = '" & ddlVisualLocation.SelectedValue.ToString() & "'", MySql)
Dim rdr As MySqlDataReader = cmd.ExecuteReader()
While rdr.Read()
lblVisualLocation.Text = rdr("Description").ToString()
End While
rdr.Close()
MySql.Close()
End Sub
Protected Sub ddlDebugLocation_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles ddlDebugLocation.SelectedIndexChanged
Dim conString As String = ConfigurationManager.ConnectionStrings("prcConnectionString").ConnectionString
Dim MySql As New MySqlConnection(conString)
MySql.Open()
Dim cmd As New MySqlCommand("SELECT * from tbcomponentlocation WHERE Location = '" & ddlVisualLocation.SelectedValue.ToString() & "'", MySql)
Dim rdr As MySqlDataReader = cmd.ExecuteReader()
While rdr.Read()
lblDebugLocation.Text = rdr("Description").ToString()
End While
rdr.Close()
MySql.Close()
End Sub