How do I check if selected value of the DropDown List is not selected in C#?

Posted by Sahat on Stack Overflow See other posts from Stack Overflow or by Sahat
Published on 2010-06-14T00:20:15Z Indexed on 2010/06/14 0:22 UTC
Read the original article Hit count: 1076

Filed under:
|
|

This code will display the selected value from the drop down list. E.g. if I sellect Item 1 I will get the following output: You have selected Item 1.

Label1.Text = "You have selected " + DropDownList1.SelectedValue + "<br />";

But if I don't select anything and click on Submit button, I will get: You have selected

What would I need to make it display "You have not selected anything. Please select at least 1 item."

© Stack Overflow or respective owner

Related posts about c#

Related posts about dropdownlist