Solved

c# asp.net dropdownlist - how to have it so the first item is not visible

Posted on 2007-03-27
2
196 Views
Last Modified: 2010-04-16
simple question!

I have a number of dropdownLists with auto post back set to true.

dropdownlist 2 is dependent on the selection from dropdownlist 1 etc.....

how can I get it so that when each dropdownlist is populated the first item is not visible as I cannot select that item.  I have to select the second item and then re-select the first item before the next dropdownlist is populated.

I would like maybe for the dropdownlist to prompt the user or just appear blank before a selection is made

any idea guys?

0
Comment
Question by:jim_bob_jim
2 Comments
 
LVL 35

Accepted Solution

by:
mrichmon earned 250 total points
ID: 18800674
You have to add a blank option to the dropdown list.

dropdownlistID.Items.Insert(0, new ListItem("", ""));
0
 

Author Comment

by:jim_bob_jim
ID: 18800739
thanks
0

Featured Post

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question