Solved

asp .net dropdown list check

Posted on 2008-10-30
4
586 Views
Last Modified: 2013-12-17
I have a dropdown list and would like to know in the code behind if any item is selected from this dropdown list. If nothing is selected, I will be using a database value. How do I check that? Thanks,

c#, asp.net
0
Comment
Question by:rajeevcs
4 Comments
 
LVL 4

Accepted Solution

by:
sijishJohn earned 250 total points
ID: 22839658
try this..

if (DropDownList1.SelectedItem == null)
{

}
0
 

Assisted Solution

by:dhiraj79
dhiraj79 earned 250 total points
ID: 22842315
Add First Item as --Select-- in drop down list of Items by using edit Item  

Now check for
if (DropDownList1.SelectedValue == "--Select--")
{
 // Means nothing is selected.
}
else
{
//Something is selected.
}
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

837 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