Validate Dropdownlist using Require filed validator control in OR can we validate Dropdownlist by Requirefield validator

Introduction: In this article today I will explain how we can validate Dropdownlist using Require filed validator control in
Validate Dropdownlist using Require filed validator control

We can validate the Dropdownlist using Requirefield validator via set the InitialValue property of Requirefield validator control.

Add a webform to project. Drag and drop the Dropdownlist control from toolbox to webform.
    <fieldset style="width:30%;height:150px">
    <legend>Validate Dropdownlist using Requirefield validator control</legend>
       Please Select Country : <asp:DropDownList ID="ddlcountry" runat="server" Width="20%">
        <asp:ListItem Value="0">--Select--</asp:ListItem>
 <asp:ListItem Value="1">India</asp:ListItem>
 <asp:ListItem Value="2">China</asp:ListItem>
 <asp:ListItem Value="3">USA</asp:ListItem>
 <asp:ListItem Value="4">Russia</asp:ListItem>
 <asp:ListItem Value="5">Cuba</asp:ListItem>
 <asp:ListItem Value="6">Iran</asp:ListItem>
                <asp:RequiredFieldValidator ID="rfvcountry" ControlToValidate="ddlcountry" InitialValue="0" runat="server" ErrorMessage="Please select Country"></asp:RequiredFieldValidator>
Build and run the project.

Is this article helpful for you?

If yes post your comment to appreciate my work and fell free to contact me. You can like me on Facebook, Google+, Linkedin and Twitter via hit on Follow us Button and also can get update follow by Email.