RequiredFieldValidator wont validate DropDownList

Can't get the RFV to validate the xml populated DropDownList

Page 1 of 1

2 Replies - 8811 Views - Last Post: 03 February 2010 - 07:19 PM Rate Topic: -----

#1 becstribe  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 32
  • Joined: 09-April 09

RequiredFieldValidator wont validate DropDownList

Posted 02 February 2010 - 09:20 PM

Hi D.I.C's

I tried searching for this question on this site, but there appears to be some errors accessing the DB.
Anyway I can't get the requiredFieldValidator to validate my dropDownList. Here follows my code

<asp:UpdatePanel ID="UpdatePanel2" runat="server" RenderMode="inline" UpdateMode="conditional">
     <ContentTemplate>
         <asp:Label ID="lblProgramType" runat="server" Text="What type of program are you interested in applying for?"
               Width="255px"></asp:Label>
               <br />
         <asp:DropDownList ID="ddProgramType" runat="server" TabIndex="2" CausesValidation="True"
              ValidationGroup="ButtonNext" DataSourceID="XmProgramType" DataTextField="text" 
              DataValueField="value" >
         </asp:DropDownList>
         <asp:XmlDataSource ID="XmProgramType" runat="server" DataFile="~/App_Data/XMLfiles/ProgramType.xml"  >
         </asp:XmlDataSource>
         <asp:RequiredFieldValidator ID="rfvProgramType" 
              ControlToValidate="ddProgramType" runat="server"
              InitialValue="Please Select" Display="Dynamic"
              SetFocusonerror="true" ValidationGroup="ButtonNext"
              ErrorMessage="<b>Required Field</b><br />Please select the type of program you wish to apply for" >*</asp:RequiredFieldValidator>



and here is my xml file that populates the dropDownList
<?xml version="1.0" encoding="utf-8" ?>
<programs>
  <program text="Please Select" value="0"/>
  <program text="Undergraduate" value="Undergraduate"/>
  <program text="TAFE Pathways" value="TAFE"/>
  <program text="Tertiary Prep Program" value="TPP"/>
  <program text="IHEPP - Indigenous Pathways" value="IHEPP"/>
  <program text="Professional Development" value="Professional Development"/>
  <program text="Cross Institutional" value="Cross Institutional"/>
</programs>



Any ideas?? I've tried so many different things and I just can't understand why it wont work.
Cheers Bec

Is This A Good Question/Topic? 0
  • +

Replies To: RequiredFieldValidator wont validate DropDownList

#2 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: RequiredFieldValidator wont validate DropDownList

Posted 03 February 2010 - 08:45 AM

Set the InitialValue property of the RequiredFieldValidator to '0' (zero).

<asp:RequiredFieldValidator ID="rfvProgramType" 
              ControlToValidate="ddProgramType" runat="server"
              InitialValue="0" Display="Dynamic"
              SetFocusonerror="true" ValidationGroup="ButtonNext"
              ErrorMessage="<b>Required Field</b><br />Please select the type of program you wish to apply for" >*</asp:RequiredFieldValidator>

Was This Post Helpful? 1
  • +
  • -

#3 becstribe  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 32
  • Joined: 09-April 09

Re: RequiredFieldValidator wont validate DropDownList

Posted 03 February 2010 - 07:19 PM

Thank you so very much,
Ironically, I tried that yesterday and it just wouldn't work. Perhaps Visual Studio just needed a restart. Nothing like a restart to help things along. Thanks for your help, much appreciated :rolleyes:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1