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. Advertising

  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. Advertising

  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. 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. Mike
    Replies:
    1
    Views:
    795
  2. Andrew
    Replies:
    2
    Views:
    503
    Jukka K. Korpela
    Apr 15, 2005
  3. Code4u
    Replies:
    4
    Views:
    2,625
    Stephen Howe
    Jul 13, 2005
  4. mldardy
    Replies:
    1
    Views:
    743
    mldardy
    Dec 10, 2008
  5. Peter Kaufman

    return nth column from dropdown control

    Peter Kaufman, Feb 3, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    138
    Alvin Bruney [MVP]
    Mar 2, 2004
Loading...

Share This Page