Hi, I'm trying populate a text box with the selected item from a drop down. I am working in VS 2003. This is the code I currently have, but it's not working:
Public Function LoadDropDown()
Dim Myconn As SqlConnection
Dim Mycomm As SqlCommand
Dim dtr As SqlDataReader
Dim result
Dim sql As String
Myconn = New SqlConnection(System.Confi
guration.C
onfigurati
onSettings
.AppSettin
gs("connSt
r"))
sql = "SELECT acad_int FROM tbl_recruiter_acad_int ORDER BY acad_int ASC"
Myconn.Open()
Mycomm = New SqlCommand(sql, Myconn)
dtr = Mycomm.ExecuteReader
ddInt1.DataSource = dtr
ddInt1.DataTextField = "acad_int"
ddInt1.DataValueField = "acad_int"
ddInt1.DataBind()
ddInt1.Items.Insert(0, New ListItem("Academic Interest 1", -1))
dtr.Close()
Myconn.Close()
End Function
Private Sub ddInt1_SelectedIndexChange
d(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ddInt1.SelectedIndexChange
d
If (ddInt1.SelectedItem.Value
= -1) Then
TextBox21.Text = ""
Else
TextBox21.Text = ddInt1.SelectedItem.Value
End If
End Sub
Can someone please tell me what I'm doing wrong? I have the drop down on auto postback, but the text box remains blank. I would appreciate any help you could offer. Thank you!
Start Free Trial