hi all,
i created a validation procedure on a textbox_validating event. the procedure goes something like...
but somehow it doesn't stop the system from continuing.. what happens is on my Save Button where i have...
i'm assuming that when i click the save button, the Textbox1_Validating event is also fired since it also brings up the MessageBox. but then after pressing OK on the MessageBox, it continues to try and Update the DataTable where I get an error from the database saying that the Column does not allow null values.
also when i click Save Button, i noticed that the Textbox1_Validating Event is only fired when the cursor is on that item. basing from this, it seems that the not all Validating Events are fired when an Adapter.Update is executed.
what's the best way to validate items? should it be on the Save Button and not on the Validating event of each items?
thanks
i created a validation procedure on a textbox_validating event. the procedure goes something like...
VB.NET:
Try
If Me.Textbox1.Text = String.Empty Then
Throw New Exception("Textbox1 cannot be null")
End If
Catch ex as Exception
MessageBox.Show(ex.Message)
End Try
but somehow it doesn't stop the system from continuing.. what happens is on my Save Button where i have...
VB.NET:
Me.Validate
Me.BindingSource1.EndEdit
Me.DataAdapter1.Update(Me.DataSet1.DataTable1)
i'm assuming that when i click the save button, the Textbox1_Validating event is also fired since it also brings up the MessageBox. but then after pressing OK on the MessageBox, it continues to try and Update the DataTable where I get an error from the database saying that the Column does not allow null values.
also when i click Save Button, i noticed that the Textbox1_Validating Event is only fired when the cursor is on that item. basing from this, it seems that the not all Validating Events are fired when an Adapter.Update is executed.
what's the best way to validate items? should it be on the Save Button and not on the Validating event of each items?
thanks