Results 1 to 3 of 3

Thread: Uselecting DropDownList Item

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2003
    Posts
    90

    Uselecting DropDownList Item

    This seems like a real easy question but I can not figure it out.

    I have a DropDownList control that is bound to a dataset. This works fine, however, the DropDownList control automatically selects the first item in this list. How can I make the list start out without any item selected?

    thanks

  2. #2
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Fort Collins, CO
    Posts
    366
    Just need to insert a new item after you databind:
    PHP Code:
    protected override void OnInit(System.EventArgs e)
    {
      if (!
    Page.IsPostBack)
      {
        ...
        ...
        
    YourDropDownList.DataBind();
        
    YourDropDownList.Items.Insert(0, new ListItem("- Select -""-1"));
      }


  3. #3
    Hyperactive Member MarkusJ_NZ's Avatar
    Join Date
    Jun 2001
    Posts
    375
    Have you tried going

    YourDropDownList.SelectedItemIndex = -1

    Cheers
    MarkusJ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width