Dynamic population of drop down list

J

jagdishl

hi
I have to populate the second drop down list based on the selection
made in the previous drop down list.I have to chose between two values
in the first dropdown list i.e city and county.This is the code that I
have added to the indexch


Private Sub ddlprogtype_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ddlprogtype.SelectedIndexChanged
Const connstr As String = "Provider=sqloledb;Data
Source=Athena;Initial Catalog=OCACollections_DB;Integrated
Security=SSPI;"
Dim objConn As New OleDbConnection(connstr)
objConn.Open()
lbldisplay.Text = "Select " + ddlprogtype.SelectedValue
Dim X As String = ddlprogtype.SelectedValue
Dim strSQL As String
If X = "County" Then
strSQL = "Select CountyName from tblCounties"
ElseIf X = "City" Then
strSQL = "Select CityName from tblCities"
End If
Dim objCmd As New OleDbCommand(strSQL, objConn)
Dim objDR As OleDbDataReader
objDR = objCmd.ExecuteReader()
ddlnames.DataSource = objDR
ddlnames.DataBind()
objConn.Close()

Upon executing this my dropdown list is repeatedly populated with
"System.Data.Common.DbDataRecord".As you can see I have used a
datareader to populate the values of the second drop down list.
Please do advise as to what is wrong.
Thanks
Jagdish.l
 
G

Guest

What did you specify for the Text and Value for the ddl?
You have the ddl bound, but did you specify what in the datareader to use?
 
J

jagdishl

Hi:
Thanks for the response.I think you are asking for the ID of the
dropdown list which is ddlnames.I dont think a dropdownlist has a Text
property.I am sorry but I dont think I do understand your
question.Could you please help me out a little more with this.

Thanks
Jagdish.l
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top