Re: Selected Item

Discussion in 'ASP .Net' started by Steven Spits, Jun 22, 2004.

  1. Steven Spits

    Steven Spits Guest

    "Sunil Sabir" wrote:

    > Actually I am a bit confused about Selected Item and Selected Value
    > SelectedItem.Text and SelectedValue of dropdownlist both give the
    > name of an item in the dropdown.So why do we have two different
    > properties for outputting the text of an item of dropdown.Why cant
    > we use one instead of both. Basically I am totally confused about
    > selected item and selected value properties.


    They are not the same thing!

    First, there is a difference between value and text of an item. The text
    shown in the DropDownList can be "Male" while the value is "M". So
    "SelectedValue" will return "M" while "SelectedItem.Text" will return
    "Male".

    Second, you might wonder about "SelectedValue" and "SelectedItem.Value".
    When getting them, there is no difference. But setting them is not the same
    thing. Settings "SelectedValue" will select another item in the DropDownList
    while "SelectedItem.Value" will change the value of the currently selected
    item.

    Steven

    - - -
     
    Steven Spits, Jun 22, 2004
    #1
    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. Iain
    Replies:
    3
    Views:
    971
  2. Nathan Sokalski
    Replies:
    0
    Views:
    653
    Nathan Sokalski
    Oct 5, 2008
  3. John
    Replies:
    5
    Views:
    1,037
    dorayme
    Mar 1, 2010
  4. mldardy
    Replies:
    0
    Views:
    1,002
    mldardy
    Sep 28, 2010
  5. Nathan Sokalski

    Selected ListItem in DropDownList does not appear selected

    Nathan Sokalski, Oct 5, 2008, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    318
    Nathan Sokalski
    Oct 5, 2008
Loading...

Share This Page