Validate required drop down lists.
Description: Use a CompareValidator to ensure that the user has made a valid selection from a drop down list.
Link: http://www.codekeep.net/snippets/56f51d03-b35d-4e87-8033-4741d4e4985b.aspx
-------------------------------------
Here are the drop down list and validator declarations.
The example here is a list of products.
-------------------------------------
<asp:DropDownList*Selection Required" ErrorMessage="You must select a Product"></asp:CompareValidator>
-------------------------------------
Here is the C# code to bind the list and add a default entry.
Note that the value of the default entry is -1.
-------------------------------------
lstProducts.DataSource = GetProducts();
lstProducts.DataBind();
insertDefaultItem(lstProducts);
private void insertDefaultItem(DropDownList ddl)
{
ddl.Items.Insert(0, new ListItem("<Select One>", "-1"));
}






