Selecting the nth item added to a dropdown box

Discussion in 'ASP .Net' started by sck10, Aug 10, 2006.

  1. sck10

    sck10 Guest

    Hello,

    I am using the following and am trying to figure out how to select the nth
    item of a list in a DropDownList.


    //Insert and Add items to the DropDownList
    ddlPayStatus.Items.Insert(0, new ListItem("Non Selected", "Non
    Selected"));

    This selects the value "Non Selected"
    ddlPayStatus.Items.FindByValue("Non Selected").Selected = true;

    Select the nth item
    ddlPayStatus.Items.IndexOf(0).Selected = true;

    Thanks, sck10
     
    sck10, Aug 10, 2006
    #1
    1. Advertisements

  2. Hi,

    You can use the SelectedIndex property to change the selected item in
    DropDownList:

    dropDownList1.SelectedIndex = 0;

    Hope this helps. Please feel free to post here if anything is unclear.

    Regards,
    Walter Wang (, remove 'online.')
    Microsoft Online Community Support

    ==================================================
    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.
    ==================================================

    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Walter Wang [MSFT], Aug 11, 2006
    #2
    1. Advertisements

  3. sck10

    sck10 Guest

    Thanks Walter...

    "Walter Wang [MSFT]" <> wrote in message
    news:...
    > Hi,
    >
    > You can use the SelectedIndex property to change the selected item in
    > DropDownList:
    >
    > dropDownList1.SelectedIndex = 0;
    >
    > Hope this helps. Please feel free to post here if anything is unclear.
    >
    > Regards,
    > Walter Wang (, remove 'online.')
    > Microsoft Online Community Support
    >
    > ==================================================
    > When responding to posts, please "Reply to Group" via your newsreader so
    > that others may learn and benefit from your issue.
    > ==================================================
    >
    > This posting is provided "AS IS" with no warranties, and confers no
    > rights.
    >
     
    sck10, Aug 11, 2006
    #3
    1. Advertisements

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. Brian Candy

    Dropdown List Box - Adding an item value

    Brian Candy, Feb 20, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    519
    Jose Marcenaro
    Feb 20, 2004
  2. =?Utf-8?B?TWVyZGFhZA==?=

    How to pop up a textedit box after selecing a dropdown item

    =?Utf-8?B?TWVyZGFhZA==?=, Oct 22, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    389
    =?Utf-8?B?TWVyZGFhZA==?=
    Oct 25, 2004
  3. Mike
    Replies:
    1
    Views:
    1,069
  4. Andrew
    Replies:
    2
    Views:
    619
    Jukka K. Korpela
    Apr 15, 2005
  5. Code4u
    Replies:
    4
    Views:
    2,965
    Stephen Howe
    Jul 13, 2005
  6. mldardy
    Replies:
    1
    Views:
    899
    mldardy
    Dec 10, 2008
  7. Peter Kaufman

    return nth column from dropdown control

    Peter Kaufman, Feb 3, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    217
    Alvin Bruney [MVP]
    Mar 2, 2004
  8. Andy Fish
    Replies:
    1
    Views:
    163
    Csaba Gabor
    Jun 15, 2005
Loading...