I needed to add a DropDownList to a ASP.NET form. Unlike forms I had used before, I wanted to make sure a different value was selected other than the top one in the list. So, the first solution I researched was to set a default value. This was accomplished with the Selected=”True” attribute.
The second condition I wanted to figure out was how to make sure something else besides the default value wasn’t still selected. That was handled using a RequiredFieldValidor and setting the InitialValue field.
<asp:DropDownList ID=”dropELLIPTICALCOMETScometname” runat=”server” Width=”270px” Height=”22px”>
<asp:ListItem Value=”Select Comet” Selected=”True”>–Select Comet–</asp:ListItem>
<asp:RequiredFieldValidator ID=”RequiredFieldValidator9″ runat=”server” ControlToValidate=”dropELLIPTICALCOMETScometname” CssClass=”ErrorMessage” Display=”Dynamic” ErrorMessage=”Select Comet Name” InitialValue=”Select Comet”></asp:RequiredFieldValidator>