Results 1 to 3 of 3

Thread: [RESOLVED] Drop down list option disappears

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    589

    Resolved [RESOLVED] Drop down list option disappears

    If I write ...

    Code:
    <asp:ListItem Value="0">--Select Category --</asp:ListItem>
    ... it creates an <option> in a <select> drop-down list.

    To populate the drop-down list I am doing something like this to get the list items from a database:

    Code:
                    conn.Open()
                    reader = categoryComm.ExecuteReader()
                    categoryList.DataSource = reader
                    categoryList.DataValueField = "CategoryID"
                    categoryList.DataTextField = "Category"
                    categoryList.DataBind()
                    reader.Close()
    ... which works fine. But, when I populate the list from the database it deletes the <asp:ListItem> so it no longer says --Select Category-- at the top of the list. The list only contains the items from the database.

    How can I get the --Select Category-- option to stay there?

    Thanks for any help.

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Drop down list option disappears

    It has to be a part of the list that is returned by the data source.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    589

    Re: Drop down list option disappears

    Thanks for your reply. But, hoping it wasn't true, I have been ferreting around and found that if you set AppendDataBoundItems to true - you can put your 'heading' category at the top and the data bound items appear beneath.

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