Advertisement

06.28.2007 at 07:34AM PDT, ID: 22664246
[x]
Attachment Details

Populate a text box with information from a drop down.

Asked by savache27 in Programming for ASP.NET, Microsoft Visual Basic.Net

Tags: box, down, drop, text

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.Configuration.ConfigurationSettings.AppSettings("connStr"))
        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_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ddInt1.SelectedIndexChanged
        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
[+][-]06.28.2007 at 07:39AM PDT, ID: 19381156

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Programming for ASP.NET, Microsoft Visual Basic.Net
Tags: box, down, drop, text
Sign Up Now!
Solution Provided By: KarinLoos
Participating Experts: 1
Solution Grade: A
 
 
[+][-]06.28.2007 at 07:54AM PDT, ID: 19381299

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32