Not sure of the best way to handle null values when not allowed
-
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:
-
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:
If you were using a
DataGridView
you'd be able to use theDataError
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.