Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populating textboxes from dropdownlist selection

Status
Not open for further replies.

jockey

Programmer
Nov 18, 2003
34
GB
Hi All

I have a drop down list that is populated from a dataset and contains customer names. On load all fine as the first customer is displayed in the list and the details for that customer populate several textboxes this like address, telphon ect.

What I can't get to work is that when I select a different customer from the list is that the details like address in the text boxes do not change. What I don't know is how to refrence the recordset details for the new customer.

Any ideas / help greatfully accepted

Jamie
 
Behind the drop down list use the event:

SelectedIndexChanged

within this event put the following code...

Code:
TextBox1.Text = DropDownList1.SelectedItem.Text;
 
Yea that is fine but it only give me what i have selected in the dropdownlist.

What I need is When I select Customer1 that teh address ect for that customer whicd are in the dataset used to fill the listbox then fill the textboxes.

Hope that make sense
 
I would use a dataview to hold you record set that way using the first example i gave to do a row filter on the dataview based on the value held in the dropdownbox.

This will give you the one record and from here you can get the other values related to the record selected.

tbAddress.Text = dvRecordSet[0]["Address"].ToString()

where dvRecordSet is the dataview.
 
I was working on the same concept the other day. Maybe this will help. It works for me....

Code:
Private Sub ddlInsured_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ddlInsured.SelectedIndexChanged

            connection.Open()
            Dim query As String = "SELECT field, field, datavaluefield, field FROM table WHERE datavaluefield LIKE '" & dropdownlist.SelectedItem.Value & "'"

            Dim objCommand As New OleDb.OleDbCommand(query, connection)
            dataadapter.SelectCommand = objCommand

            dataadapter.Fill(dataset)
            textbox1.DataBind()
            txtbox2.DataBind()
            txtbox3.DataBind()

            connection.Close()
       
    End Sub

I hope that helps you out. if you have any other questions, please let me know...

chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top