[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.
Re: Drop down list option disappears
It has to be a part of the list that is returned by the data source.
-tg
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.