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. C#
  4. Not sure of the best way to handle null values when not allowed

Not sure of the best way to handle null values when not allowed

Scheduled Pinned Locked Moved C#
questiondatabasehelptutoriallearning
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.
  • J Offline
    J Offline
    Johnny 0
    wrote on last edited by
    #1

    Good day everybody There are cases on a form when the user might create a new row for example and not complete all the mandatory information as imposed by the database. In other words if you forget to enter data in a textbox binded to a datacolumn that does not allow nulls. In that case if the user leaves the row somehow a NoNullAllowedException will be thrown. My problem is I am not sure what is the best way to handle this. I thaught i could c,apture an event on the BindinSource but there is no "PositionChanging" event there is just a PositionChanged event, which of course is too late. I could also take care of the case in the form itself but it seems like a lot of code for something that could be so simple. Any suggestions? Very confused :confused:

    B 1 Reply Last reply
    0
    • J Johnny 0

      Good day everybody There are cases on a form when the user might create a new row for example and not complete all the mandatory information as imposed by the database. In other words if you forget to enter data in a textbox binded to a datacolumn that does not allow nulls. In that case if the user leaves the row somehow a NoNullAllowedException will be thrown. My problem is I am not sure what is the best way to handle this. I thaught i could c,apture an event on the BindinSource but there is no "PositionChanging" event there is just a PositionChanged event, which of course is too late. I could also take care of the case in the form itself but it seems like a lot of code for something that could be so simple. Any suggestions? Very confused :confused:

      B Offline
      B Offline
      bobsugar222
      wrote on last edited by
      #2

      If you were using a DataGridView you'd be able to use the DataError event (I think that's the name) to capture it. You may have to handle it manually on a 'Save' )by checking a value isn't null before committing to the DataSet / DB) if you're using your own custom GUI for editing rows.

      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