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!

How to assign a textbox.text value to selected dropdownlist value

Status
Not open for further replies.

golyg

Programmer
Jul 22, 2002
319
US
I have a page where the user selects a product. I wish to then populate the textbox value with the selected ddl value to allow them to update the value if necessary.

Here's my code:
Code:
Protected Sub ddlProductFamilies_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlProductFamilies.SelectedIndexChanged

        txbProductFamilyUp.Text = ddlProductFamilies.SelectedValue.ToString

End Sub

When I debug this, txbProductFamilyUp value appears to be assigned the ddlProductFamilies.SelectedValue but when I return to the page, the textbox is null.

Any ideas?
TY
 


That will only work if you've explicitly set the dropdown value the same as the text. Try ddlProductFamilies.SelectedText


Mark

"You guys pair up in groups of three, then line up in a circle."
- Bill Peterson, a Florida State football coach
 
Also check if there is other code in the codebehind that would overwrite the value.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top