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
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