Form Validate Pulldown (RequiredFieldValidator)

I want to do an asp:RequiredFieldValidator on the drop down below. How can I make the validator text activate if Food Types's selected value = 0?


<asp:DropDownList runat="server" id="Food Type">

      <asp:ListItem Values="0" Selected="True">Please Select</asp:ListItem>
                                                                  <asp:ListItem Value="1">Chicken</asp:ListItem>
                                                                  <asp:ListItem Value="2">Beef</asp:ListItem>
                                                                  <asp:ListItem Value="3">Fish</asp:ListItem>
                                                                        </asp:DropDownList>
LVL 1
net_susanAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Elvio Lujan.Net Senior DeveloperCommented:
use an compare validator whit the comparevalue=0 and the operator=greatherthan
Elvio Lujan.Net Senior DeveloperCommented:
<asp:CompareValidator id="cv" runat="server" Operator="GreaterThan" ValueToCompare="0" Type="Integer"
      ErrorMessage="Valor requerido" ControlToValidate="Food Type" cssclass="Error"></asp:CompareValidator>
Oliver AmayaEntrepeneurCommented:
Hi, you can use a normal RequiredFieldValidator and set its InitialValue property to 0:

<asp:RequiredFieldValidator id="rvFood" runat="server" ControlToValidate="Food Type" InitialValue="0"/>

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
net_susanAuthor Commented:
Both ways worked like this:

<asp:CompareValidator id="cv" runat="server" Operator="GreaterThan" ValueToCompare="0" Type="Integer" ControlToValidate="FoodType">Please select your food type!</asp:CompareValidator>

<asp:RequiredFieldValidator ID="rvFood" ControlToValidate="FoodType" Runat="server" InitialValue="0">Please select your food type!</asp:RequiredFieldValidator>      
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.