DropDownList - Is it Possible to get the TextField Contents

Discussion in 'ASP .Net Web Controls' started by page77.office@googlemail.com, May 30, 2006.

  1. Guest

    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
     
    , May 30, 2006
    #1
    1. Advertising

  2. mnichols Guest

    mnichols, May 30, 2006
    #2
    1. Advertising

  3. Guest

    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
     
    , May 30, 2006
    #3
  4. Try this:

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

    Hope that helps

    <> wrote in message
    news:...
    > 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
    >
     
    Colin McKenney, Jun 15, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Don Adams
    Replies:
    1
    Views:
    626
    Martin Honnen
    Mar 5, 2004
  2. mosscliffe
    Replies:
    7
    Views:
    375
    Mark Rae
    May 31, 2006
  3. Anthony Papillion

    How to get or set the text of a textfield?

    Anthony Papillion, Jul 11, 2011, in forum: Python
    Replies:
    5
    Views:
    429
    John Gordon
    Jul 11, 2011
  4. Kamarulnizam Rahim
    Replies:
    4
    Views:
    249
    Robert Klemme
    Jan 28, 2011
  5. Pål Sindre  Hiåsen

    get and put value from a dynamicly created textfield

    Pål Sindre Hiåsen, May 21, 2005, in forum: Javascript
    Replies:
    3
    Views:
    107
    Thomas 'PointedEars' Lahn
    May 27, 2005
Loading...

Share This Page