Solved

asp .net dropdown list check

Posted on 2008-10-30
4
579 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

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…
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…
A short film showing how OnPage and Connectwise integration works.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

932 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now