A binding navigator control adds the following code for when the Save button is clicked:
Me.Validate()
Me.UserBindingS ource.EndEdit()
Me.UserTableAda pter.Update(Me. UserDataSet.Use r)"
You can add code to the column changing event for the dataset by using the dataset designer, for example:
Private Sub UserDataTable_C olumnChanging(B yVal sender As System.Object, ByVal e As System.Data.Dat aColumnChangeEv entArgs) Handles Me.ColumnChangi ng
If (e.Column.Colum nName = Me.WindowsLogin Column.ColumnNa me) Then
If CType(e.Propose dValue, String) = "" Then
e.Row.SetColumn Error(e.Column, "Cannot be blank")
Else
e.Row.SetColumn Error(e.Column, "")
End If
End If
The problem is, the validation is not actually done until the .EndEdit event is fired. Me.Validate can be overriden for form validation (not validation on the dataset columns). So EndEdit throws a runtime error say if you have Null for a column that does not allow Nulls. I'm having a very hard time getting my validation to work using the error provider rather than throwing runtime errors. Help!
Me.Validate()
Me.UserBindingS ource.EndEdit()
Me.UserTableAda pter.Update(Me. UserDataSet.Use r)"
You can add code to the column changing event for the dataset by using the dataset designer, for example:
Private Sub UserDataTable_C olumnChanging(B yVal sender As System.Object, ByVal e As System.Data.Dat aColumnChangeEv entArgs) Handles Me.ColumnChangi ng
If (e.Column.Colum nName = Me.WindowsLogin Column.ColumnNa me) Then
If CType(e.Propose dValue, String) = "" Then
e.Row.SetColumn Error(e.Column, "Cannot be blank")
Else
e.Row.SetColumn Error(e.Column, "")
End If
End If
The problem is, the validation is not actually done until the .EndEdit event is fired. Me.Validate can be overriden for form validation (not validation on the dataset columns). So EndEdit throws a runtime error say if you have Null for a column that does not allow Nulls. I'm having a very hard time getting my validation to work using the error provider rather than throwing runtime errors. Help!
Comment