R
Ryan
A binding navigator control adds the following code for when the Save button is clicked:
Me.Validate()
Me.UserBindingSource.EndEdit()
Me.UserTableAdapter.Update(Me.UserDataSet.User)"
You can add code to the column changing event for the dataset by using the dataset designer, for example:
Private Sub UserDataTable_ColumnChanging(ByVal sender As System.Object, ByVal e As System.Data.DataColumnChangeEventArgs) Handles Me.ColumnChanging
If (e.Column.ColumnName = Me.WindowsLoginColumn.ColumnName) Then
If CType(e.ProposedValue, String) = "" Then
e.Row.SetColumnError(e.Column, "Cannot be blank")
Else
e.Row.SetColumnError(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.UserBindingSource.EndEdit()
Me.UserTableAdapter.Update(Me.UserDataSet.User)"
You can add code to the column changing event for the dataset by using the dataset designer, for example:
Private Sub UserDataTable_ColumnChanging(ByVal sender As System.Object, ByVal e As System.Data.DataColumnChangeEventArgs) Handles Me.ColumnChanging
If (e.Column.ColumnName = Me.WindowsLoginColumn.ColumnName) Then
If CType(e.ProposedValue, String) = "" Then
e.Row.SetColumnError(e.Column, "Cannot be blank")
Else
e.Row.SetColumnError(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!