Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. how to validate Dropdownlist in ASP.NET

how to validate Dropdownlist in ASP.NET

Scheduled Pinned Locked Moved ASP.NET
helpcsharpasp-nettutorial
7 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    findtango
    wrote on last edited by
    #1

    hi to all i have a dropdownlist on page try to validate through RequiredfieldValidater BUT it is not working. i think the possible error in Initial value property of required field validator.. plz. help me how to implement validation on dropdownlist and sent some sample code if possble thanks john

    P J U B 4 Replies Last reply
    0
    • F findtango

      hi to all i have a dropdownlist on page try to validate through RequiredfieldValidater BUT it is not working. i think the possible error in Initial value property of required field validator.. plz. help me how to implement validation on dropdownlist and sent some sample code if possble thanks john

      P Offline
      P Offline
      Pradip Kishore
      wrote on last edited by
      #2

      can you specify what exactly you want to validate..?

      pradip kishore

      1 Reply Last reply
      0
      • F findtango

        hi to all i have a dropdownlist on page try to validate through RequiredfieldValidater BUT it is not working. i think the possible error in Initial value property of required field validator.. plz. help me how to implement validation on dropdownlist and sent some sample code if possble thanks john

        J Offline
        J Offline
        J4amieC
        wrote on last edited by
        #3

        I have used a RequiredFieldValidator for dropdown lists loads of times. The only thing to remember is to set InitialValue to whatever the value of your "Please Select" entry is.

        --- How to get answers to your questions[^]

        1 Reply Last reply
        0
        • F findtango

          hi to all i have a dropdownlist on page try to validate through RequiredfieldValidater BUT it is not working. i think the possible error in Initial value property of required field validator.. plz. help me how to implement validation on dropdownlist and sent some sample code if possble thanks john

          U Offline
          U Offline
          unchecked
          wrote on last edited by
          #4

          Hi! What I did in my project is that, I inserted a new Listitem at index 0 of my dropdownlist with, say, value of "-1". then I added a CompareValidator control with properties: Type="String"; ControlToValidate="MyDropdownList"; ValueToCompare="-1" Operator="NotEqual"; coded like -> Note that the ValueToCompare's value is the same as the ListItem value I added to my dropdownlist, and the Operator is "NotEqual". hope it helps.. //mastereuo On Error Goto Hell

          J 1 Reply Last reply
          0
          • U unchecked

            Hi! What I did in my project is that, I inserted a new Listitem at index 0 of my dropdownlist with, say, value of "-1". then I added a CompareValidator control with properties: Type="String"; ControlToValidate="MyDropdownList"; ValueToCompare="-1" Operator="NotEqual"; coded like -> Note that the ValueToCompare's value is the same as the ListItem value I added to my dropdownlist, and the Operator is "NotEqual". hope it helps.. //mastereuo On Error Goto Hell

            J Offline
            J Offline
            J4amieC
            wrote on last edited by
            #5

            How is this any different to using a requiredFieldValidator and setting the InitialValue to -1 (in your example)

            --- How to get answers to your questions[^]

            F 1 Reply Last reply
            0
            • J J4amieC

              How is this any different to using a requiredFieldValidator and setting the InitialValue to -1 (in your example)

              --- How to get answers to your questions[^]

              F Offline
              F Offline
              findtango
              wrote on last edited by
              #6

              i set initialvalue to -1 then, it is also not working???????

              1 Reply Last reply
              0
              • F findtango

                hi to all i have a dropdownlist on page try to validate through RequiredfieldValidater BUT it is not working. i think the possible error in Initial value property of required field validator.. plz. help me how to implement validation on dropdownlist and sent some sample code if possble thanks john

                B Offline
                B Offline
                Britney S Morales
                wrote on last edited by
                #7

                This my solution, you must to create a dropdownlist with only one item, the text is '-' y el value is the same... So, insert a COMPAREVALIDATOR and make this changes ControltoValidate: the dropdownlist Operator: Not Equal ValuetoCompare: - (Its the line) Thats all, the validator fireup if you choose the line value Best regards :rose:

                keep Learning and you never will be out of date...

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups