Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

<asp:DropDownList>  OnSelectedIndexChanged

Posted on 2004-09-01
2
Medium Priority
?
283 Views
Last Modified: 2012-05-05

I have a databound <asp:DropDownList> so it immediately has the first item from the database as the first ListItem:

<option value="1">Desktops</option>
<option value="2">Notebooks</option>
<option value="3">Monitors</option>

  What do I do so that I can make something that is an equivalent to:
 <option>--</option>  that has no value?

The reason I am asking is because if the first item from the database (Desktops) is the one the user wants to select then I can't get it to do a OnSelectedIndexChanged.  I figure if it shows a blank ListItem then the user will have to change the index to select Desktops and trigger the event.

I'd appreciate any solution to this--either some kind of <option>--</option> or some way that if they picked "Desktops" it would still trigger event.

Thanks
0
Comment
Question by:champ_010
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 10

Accepted Solution

by:
jnhorst earned 500 total points
ID: 11959187
Here you go:

Right after you call DataBind() on the dropdpwn list, do this (I'll use "ddl" as the name of the drop down list):

ddl.Items.Insert(0, "");

This will add that blank option to appear first in the list (the "0" is in index at which you want the item added).

John
0
 
LVL 1

Author Comment

by:champ_010
ID: 11959262
Nice!  I'll be using that one alot.  Thanks John.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

604 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