DropDownList Item Selected doesn't work?

Discussion in 'ASP .Net' started by Rudy Ko, Apr 27, 2005.

  1. Rudy Ko

    Rudy Ko Guest

    Hi,

    I seem unable to set the selected item in a DropDownList by using the
    following code, it always return the toppest (index 0) item, no matter what
    i selected.

    list.DataSource = GetProductDataSource();
    list.DataBind();
    item = list.Items.FindByValue("UMTS");
    if(item != null)
    item.Selected = true;
    I steped into the code, and I'm sure that item has been set to true, but the
    page still return the toppest item. Anyone can help??
    Rudy Ko, Apr 27, 2005
    #1
    1. Advertising

  2. On Wed, 27 Apr 2005 12:00:27 -0400 in
    microsoft.public.dotnet.framework.aspnet, "Rudy Ko" <>
    wrote:

    >Hi,
    >
    >I seem unable to set the selected item in a DropDownList by using the
    >following code, it always return the toppest (index 0) item, no matter what
    >i selected.
    >
    >list.DataSource = GetProductDataSource();
    >list.DataBind();
    >item = list.Items.FindByValue("UMTS");
    >if(item != null)
    > item.Selected = true;
    >I steped into the code, and I'm sure that item has been set to true, but the
    >page still return the toppest item. Anyone can help??
    >

    Try,

    list.SelectedValue = "UMTS";

    Roger
    Roger Helliwell, Apr 28, 2005
    #2
    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. Wayne Erfling
    Replies:
    0
    Views:
    453
    Wayne Erfling
    Oct 13, 2006
  2. Iain
    Replies:
    3
    Views:
    918
  3. Nathan Sokalski
    Replies:
    0
    Views:
    595
    Nathan Sokalski
    Oct 5, 2008
  4. mldardy
    Replies:
    0
    Views:
    952
    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:
    282
    Nathan Sokalski
    Oct 5, 2008
Loading...

Share This Page