DropDownList - Is it Possible to get the TextField Contents

P

page77.office

Is it possible to get at the textfield of a SelectedValue in a drop
down list box ?

If not I can think of two possible solutions

1) Requery the database

2) copy the dropdownlist to an arraylist in memory and get the text
value from the list

Any help appreciated
 
C

CaffieneRush

We're a bit puzzled because it seems like you answered your own
question - the SelectedValue of the DropDownList will give you the
value of the selected listitem within the ddl.

If you want the actual control itself then SelectedItem property is
what you want.
Eg..
Dim textbox1 As Textbox = CType(DropDownList1.SelectedItem, TextBox)
Dim textValue As String = textbox1.Text

If you are not getting the value you expect back then you're probably
accessing the value is the incorrect phase of the lifecycle or have
overwritten your values or something else I haven't thought about.

Regards,
Andy
 
C

Colin McKenney

Try this:

Dim selItemText As New ListItem
selItemText = DropDownList.Items(DropDownList.SelectedIndex)
Label.Text = selItemText.Text

Hope that helps
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top