How do I check if selected value of the ListBox 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:52 UTC
Read the original article Hit count: 169

This code will display the selected value from the listbox. 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."

UPDATE: I am using ASP.NET WebForms.

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET