Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7929859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:13:40+00:00 2026-06-03T20:13:40+00:00

I have a DropDownList in my asp.net web page. The RequiredFieldValidator is not working.

  • 0

I have a DropDownList in my asp.net web page.
The RequiredFieldValidator is not working. Thanks for looking at my code.

<asp:DropDownList ID="Organization" runat="server"
    DataSourceID="OrganizationList"
    DataTextField="OrgName" DataValueField="OrgCode" CausesValidation="True">
</asp:DropDownList>

<asp:SqlDataSource ID="OrganizationList" runat="server"
    ConnectionString="<%$ ConnectionStrings:MembershipDB %>"
    SelectCommand="Admin_GetOrganizationDropDown" 
    SelectCommandType="StoredProcedure"></asp:SqlDataSource>

<asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidatorOrg"
    ControlToValidate="Organization"
    ErrorMessage="Organization is required." 
    Display="Dynamic" />
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T20:13:42+00:00Added an answer on June 3, 2026 at 8:13 pm

    If you have not allready done it you should have a value that means that you are not selecting anything. Like this:

     Organization.Insert(0,new ListItem("--Select--","0"));
    

    And then you need to tell the asp:RequiredFieldValidator to check for a value that you are not allowing. So InitialValue value should be 0. Like this:

    <asp:RequiredFieldValidator InitialValue="0"
    

    Then when the --Select-- option is chosen and you try to submit the page. The asp:RequiredFieldValidator will fire.

    Edit

    I don’t like the look of the bit of sql you are showing:

    Select Distinct 
        'name' As [OrgCode],'Please Select' As [OrgName] 
    FROM [MedOrganization] 
    Union All 
    SELECT [OrgCode], [OrgName] FROM [MedOrganization]
    

    Not a performance vise good piece of sql code. You can do this instead:

    Select
        'name' As [OrgCode],'Please Select' As [OrgName] 
    Union All 
    SELECT [OrgCode], [OrgName] FROM [MedOrganization]
    

    Why use the distinct there? When you can just select like above. Back to the question. You can try having the InitialValue set to name like this:

    <asp:RequiredFieldValidator InitialValue="name"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple ASP.NET web form as below: <form id=form1 runat=server> <asp:TextBox ID=txt
I have an asp.net web page with a ton of code that is handled
i have the following code in an asp.net mvc view. <% = Html.DropDownList(Filter, new
I have two DropDownList <asp:DropDownList ID=ddl1 runat=server Width=173px CssClass=ddl > </asp:DropDownList> <asp:DropDownList ID=ddl2 runat=server
I have a basic DropDownList bound to a ObjectDataSource: <asp:DropDownList ID=DropDownList1 runat=server AutoPostBack=True DataSourceID=objDataSource1
hi I have this gridview like this. <asp:DropDownList ID=triggerDropDown runat=server AutoPostBack=true onselectedindexchanged=triggerDropDown_SelectedIndexChanged> <asp:GridView ID=myGridView
I have a ASP.Net web page with a grid view. I want to filter
I have inherited some ASP.NET web code which I have made changes to. It
I have a DropDownList inside a repeater control in an ASP.NET page that has
I have an ASP.NET MVC Web Application that interacts with a SQL Server 2008

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.