I've got a simple RadGridView bound to a DataTable (through a BindingSource); standard and easy way to put a gridview on a form dragging it from datasources box.
I've implemented my business rule validation in the datatable, as below:
Private
Sub
OperazioniDataTable_ColumnChanging(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.Data.DataColumnChangeEventArgs)
Handles
Me
.ColumnChanging
Debug.Print(
"ColumnChanging: column="
& e.Column.ColumnName)
If
(e.Column.ColumnName =
Me
.impovalColumn.ColumnName)
Then
If
CType
(e.ProposedValue,
Decimal
) = 0
Then
e.Row.SetColumnError(e.Column,
"Inserire un importo diverso da zero"
)
Else
e.Row.SetColumnError(e.Column,
""
)
End
If
End
If
End
Sub
When I edit the [impoval] cell and enter 0, moving to another cell/row raises the ColumnChanging event, but no feedback at all on the grid.
Another issue: if I press [Escape] key in the cell, the value is not restored to the old one.
In the standard MS grid I get feedback and restore behaviour.
I would like to know the best practices to enforce data validation (on single cells and on row, moving away from a cell/row and/or trying to close a form, etc.), possibly avoiding to put rules in the gridview events, in order to keep all the business rules validation code in the data transfer objects.
Please don't suggest to create separate business objects, as I want to avoid this coding overhead.
TIA
Ubaldo