The blog is created to discuss Prince2 methodology any issues faced in project management to be resolved or discussed and .Net Technology
Tuesday, April 14, 2015
how to use requiredfield validator with dropdownlist
Here is how we can use requiredfieldvalidator with dropdownlist.
Set the below property of the dropdownlist control
AppendDataBoundItems = true
Then Insert a default value in the Page_Load event
ddl.Items.Insert(0, new ListItem("<<-Select-->", "-1"));
Now define the required field validator and set its initialvalue attribute to "-1"
<asp:RequiredFieldValidator ID="reqddl" runat="server" Text="*" ControlToValidate="ddlRole" InitialValue="-1" SetFocusOnError="true" Display="Dynamic" ValidationGroup="Add"></asp:RequiredFieldValidator>
Happy coding :)
Location:
Al Jubail Saudi Arabia
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment