• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 337
  • Last Modified:

required field ddl

I have a question about the ddl.. I need to be required .. and since the database is set as int.
I have to add values to all the item even the header first item "select option".. how can I make it required so the user has to change one of the options?
asp:DropDownList ID="ddlSchoolName" ValidationGroup="page1" CssClass="form_input"  runat="server">
                       <asp:ListItem Selected="true" Value="99">Select School</asp:ListItem>
                       <asp:ListItem Value="1">Santee Educational Complex</asp:ListItem>
                       <asp:ListItem Value="2">Jefferson</asp:ListItem>
                       <asp:ListItem Value="3">Dorsey</asp:ListItem>
                       <asp:ListItem Value="4">Fremont</asp:ListItem>
                       <asp:ListItem Value="5">West Adams</asp:ListItem></asp:DropDownList>

Open in new window

  • 3
1 Solution
Try this.
<asp:RequiredValidator runat="server" id="val1" controltovalidate="ddSchoolName" InitialValue="select option"></asp:RequiredValidator>

Open in new window

Oh dont forget to add an error message like this

ErrorMessage="Blah Blah"
RomacaliAuthor Commented:
humm I got this error:
 Unknown server tag 'asp:RequiredValidator'.

Source Error:

Line 83:                        <asp:ListItem Value="4">Fremont</asp:ListItem>
Line 84:                        <asp:ListItem Value="5">West Adams</asp:ListItem></asp:DropDownList>
Line 85:                        <asp:RequiredValidator runat="server" id="val1" controltovalidate="ddSchoolName" InitialValue="Select School"></asp:RequiredValidator></td>
Crap Sorry.

Change <asp:RequiredValidator  to <asp:RequiredFieldValidator and </asp:RequiredFieldValidator>
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now