SelectedIndexChanged

mattyfed

Member
Joined
Jul 2, 2004
Messages
9
Programming Experience
1-3
I have a drop-down menu, and a text box. When the user selects an item from the drop-down menu, I would like to have the textbox.text update to reflect the DropDown.SelectedValue

I know this should be easy but....

This code obviously is not working:
Private Sub DropDown_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DropDown.SelectedIndexChanged

txtBox.Text = DropDown.SelectedValue

End Sub

Any suggestions? Thanks.
 

TPM

Well-known member
Joined
Dec 7, 2004
Messages
623
Location
CA
Programming Experience
3-5
Have you bound a value?
 

mattyfed

Member
Joined
Jul 2, 2004
Messages
9
Programming Experience
1-3
For this I am just using a dropdown list containing 5 standard menu options, but, the overall goal is to have a dropdown list of states, which is fed by an DB table. When the user selects a state, the text box should automatically populate with the zip codes for that state (which are also stored in the DB).
 

TPM

Well-known member
Joined
Dec 7, 2004
Messages
623
Location
CA
Programming Experience
3-5
Ok so you want to use selectedtext then not selectedvalue.
 

mattyfed

Member
Joined
Jul 2, 2004
Messages
9
Programming Experience
1-3
I am not sure??? VisualStudio does not offer that as an option for this element?
 

TPM

Well-known member
Joined
Dec 7, 2004
Messages
623
Location
CA
Programming Experience
3-5
Sorry, selectedtext is for combobox's. Yes you want the selecteditem.
 

mattyfed

Member
Joined
Jul 2, 2004
Messages
9
Programming Experience
1-3
It does seems that when I select an item from the dropdown, a postback is not occurring even though I have a Private Sub DropDown_SelectedIndexChanged

Should this force a postback?
 

TPM

Well-known member
Joined
Dec 7, 2004
Messages
623
Location
CA
Programming Experience
3-5
Set your autopostback to true.
 

TPM

Well-known member
Joined
Dec 7, 2004
Messages
623
Location
CA
Programming Experience
3-5
Cool. No problem.
 
Top Bottom