Environment:
LLBLGenPro Demo (latest version)
Windows Forms .Net 2.0 SelfServicing
Infragistics ultraGrid version 6.3
I have a grid and the data is validated each time the user moves to a new row.
(see code below)
public partial class CurrencyEntity : EntityBase, ISerializable
{
protected override void OnValidateEntityBeforeSave()
{
base.OnValidateEntityBeforeSave();
// Currency.Code Validations
if (Code.Length == 2)
{
SetEntityFieldError("Code", string.Empty, false);
}
else
{
SetEntityFieldError("Code", "Code must be two characters in length", false);
}
// Currency.Description Validations
if (Description.Length == 5)
{
SetEntityFieldError("Description", string.Empty, false);
}
else
{
SetEntityFieldError("Description", "Description must be five characters in length", false);
}
}
protected internal void ultraGrid1_AfterRowUpdate(object sender, RowEventArgs e)
{
// ultraGrid1BS is a BindingSource
((EntityClasses.CurrencyEntity)(ultraGrid1BS.Current)).Save();
}
The databinding is setup a follows:
CurrencyEntityCollection is the datasource for ultraGrid1BS --> BindingSource
ultraGrid1BS is the datasource for ultraGrid1
When I run the code above the validations work I get the appropriate error messages associated with the correct rows and cells. However despite the data showing up as invalid it is being persisted to the database. I don't understand this because validation is supposed to execute prior to any entity.save() and so invalid changes should not be persisted?
Can you please advise what I might be doing wrong?
Thanks