You can use the RequiredFieldValidator control’s InitialValue property to specify a default value other than an empty string.
The RequiredFieldValidator control includes an InitialValue property. The value of the first list from the DropDownList control is assigned to this property.
Example
- <asp:DropDownList id="dropFavoriteColor" Runat="server">
- <asp:ListItem Text="Select Color" Value="none" />
- <asp:ListItem Text="Red" Value="Red" />
- <asp:ListItem Text="Blue" Value="Blue" />
- <asp:ListItem Text="Green" Value="Green" />
- </asp:DropDownList>
-
- <asp:RequiredFieldValidator id="reqFavoriteColor" Text="(Required)" InitialValue="none" ControlToValidate="dropFavoriteColor" Runat="server" />