To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
VBForums  

VB Wire News
Part 10 of the Visual Basic .NET 2010 Express Tutorial Complete!
How to Use the Visual Studio Code Analysis Tool FxCop
Article :: Interview with Andrei Alexandrescu (Part 3 of 3)
Introducing Visual Studio LightSwitch
Visual Studio LightSwitch Beta 1 is Available



Go Back   VBForums > Visual Basic > Visual Basic .NET

Reply Post New Thread
 
Thread Tools Display Modes
Old Jul 5th, 2007, 04:02 PM   #1
Webskater
Hyperactive Member
 
Join Date: Nov 06
Posts: 420
Webskater is an unknown quantity at this point (<10)
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.
Webskater is offline   Reply With Quote
Old Jul 5th, 2007, 04:15 PM   #2
techgnome
Snarky...
 
techgnome's Avatar
 
Join Date: May 02
Posts: 15,476
techgnome has a brilliant future (2000+)techgnome has a brilliant future (2000+)techgnome has a brilliant future (2000+)techgnome has a brilliant future (2000+)techgnome has a brilliant future (2000+)techgnome has a brilliant future (2000+)techgnome has a brilliant future (2000+)techgnome has a brilliant future (2000+)techgnome has a brilliant future (2000+)techgnome has a brilliant future (2000+)techgnome has a brilliant future (2000+)
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 requests for help. It's not conducive to the general learning of others.-I also subscribe to all threads I participate, so there's no need to pm when there's an update.*
* 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???
* On Error Resume Next is error ignoring, not error handling(tm). * Use Offensive Programming, not Defensive Programming.
"There is a major problem with your code, and VB wants to tell you what it is.. but you have decided to put your fingers in your ears and shout 'I'm not listening!'" - si_the_geek on using OERN
MVP '06-'10
techgnome is offline   Reply With Quote
Old Jul 5th, 2007, 05:54 PM   #3
Webskater
Hyperactive Member
 
Join Date: Nov 06
Posts: 420
Webskater is an unknown quantity at this point (<10)
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.
Webskater is offline   Reply With Quote
Reply

Go Back   VBForums > Visual Basic > Visual Basic .NET


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 05:35 AM.





Acceptable Use Policy

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.