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
MSDN Subscribers: Download the VS 2010 Release Candidate
MSDN Subscribers: Download the VS 2010 Release Candidate
Sell Your Code and Make Money?
Creating your own Tetris game using VB.NET
Article :: Improving Software Economics, Part 4 of 7: Top 10 Principles of Iterative Software Management



Go Back   VBForums > Visual Basic > Visual Basic .NET

Reply Post New Thread
 
Thread Tools Search this Thread Display Modes
Old Jul 5th, 2007, 05:02 PM   #1
Webskater
Hyperactive Member
 
Join Date: Nov 06
Posts: 385
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, 05:15 PM   #2
techgnome
Invisible
 
Join Date: May 02
Posts: 13,261
techgnome has much to be proud of (1500+)techgnome has much to be proud of (1500+)techgnome has much to be proud of (1500+)techgnome has much to be proud of (1500+)techgnome has much to be proud of (1500+)techgnome has much to be proud of (1500+)techgnome has much to be proud of (1500+)techgnome has much to be proud of (1500+)techgnome has much to be proud of (1500+)techgnome has much to be proud of (1500+)techgnome has much to be proud of (1500+)
Re: Drop down list option disappears

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

-tg
__________________
How to Use Parameters
* 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.*
* Got Eels in your Hovercraft? *
* Your guide to The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
*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, 06:54 PM   #3
Webskater
Hyperactive Member
 
Join Date: Nov 06
Posts: 385
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 Search this Thread
Search this Thread:

Advanced Search
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 01:13 PM.




To view more projects, click here

Acceptable Use Policy


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.