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. General Programming
  3. Visual Basic
  4. Validation for Dropdown list

Validation for Dropdown list

Scheduled Pinned Locked Moved Visual Basic
database
2 Posts 2 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.
  • B Offline
    B Offline
    BORN again
    wrote on last edited by
    #1

    I am using a 'Required Field Validator' for my Dropdown list but it doesn't work , if I do not select any thing from the list it still saves the form and I guess that is necause it assmues the first entry in the list as selected always no matter what the first item is. I also tried using 'Range Validator' to see that the item selected from the dropdown is between 2 & 10... item no 1 in the dropdown is 'Please Select' , but that is not working as well.. does anyone have an idea as to which validator will work to see that the user HAS selected an entry from the dropdown else the form will not save. Thank you for your precious time invested in answering this query. Aartee. ...HE is watching Us All!

    G 1 Reply Last reply
    0
    • B BORN again

      I am using a 'Required Field Validator' for my Dropdown list but it doesn't work , if I do not select any thing from the list it still saves the form and I guess that is necause it assmues the first entry in the list as selected always no matter what the first item is. I also tried using 'Range Validator' to see that the item selected from the dropdown is between 2 & 10... item no 1 in the dropdown is 'Please Select' , but that is not working as well.. does anyone have an idea as to which validator will work to see that the user HAS selected an entry from the dropdown else the form will not save. Thank you for your precious time invested in answering this query. Aartee. ...HE is watching Us All!

      G Offline
      G Offline
      Gavin Jeffrey
      wrote on last edited by
      #2

      use the custom validator - private void CustomValidator1_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args) { if ( !dropdown.SelectedIndex == 0 ) args.IsValid = false; }

      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