I have a form with two drop down boxes. The first one, dropCounty is fine. But I'd like for the second one, dropCity to depend on dropCounty for the value. I would like for the dropCity box to show only cities that are for the certain county that was chosen. I would like for the second drop down box to be hidden until the person has chosen a county. Can someone please help me with the code for this?
Here's my code:
'----------------------------------------------------------------
' name: BindCountyList() - Fine
'----------------------------------------------------------------
Sub BindCountyList()
Dim strConnect As String
Dim conCounty As New System.Data.SqlClient.SQLConnection
Dim cmdSelect As New System.Data.SqlClient.SQLCommand
Dim dtrCounty As System.Data.SqlClient.SqlDataReader
'Get connection string from Web.Config
strConnect = ConfigurationSettings.AppSettings("ConnectionString")
conCounty = New System.Data.SqlClient.SQLConnection(strConnect)
conCounty.Open()
cmdSelect = New System.Data.SqlClient.SQLCommand( "Select CountyID, County From County Order by County", conCounty)
dtrCounty = cmdSelect.ExecuteReader()
dropCounty.DataSource = dtrCounty
dropCounty.DataValueField = "CountyID"
dropCounty.DataTextField = "County"
dropCounty.DataBind()
'Add and select a "Select County" option for the DDL
dropCounty.Items.Insert(0, new ListItem("Select County", ""))
dropCounty.SelectedIndex = 0
dtrCounty.Close()
&nbs