If you are using a data source, here's another way to do it without code behind.
Note the following key points:
ListItem
of Value="0"
is on the source page, not added in codeListItem
in the source will be overwritten if you don't include
AppendDataBoundItems="true"
in the DropDownList
InitialValue="0"
tells the validator that this is the value that
should fire that validator (as pointed out in other answers)Example:
<asp:DropDownList ID="ddlType" runat="server" DataSourceID="sdsType"
DataValueField="ID" DataTextField="Name" AppendDataBoundItems="true">
<asp:ListItem Value="0" Text="--Please Select--" Selected="True"></asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="rfvType" runat="server" ControlToValidate="ddlType"
InitialValue="0" ErrorMessage="Type required"></asp:RequiredFieldValidator>
<asp:SqlDataSource ID="sdsType" runat="server"
ConnectionString='<%$ ConnectionStrings:TESTConnectionString %>'
SelectCommand="SELECT ID, Name FROM Type"></asp:SqlDataSource>