I'm using SetEntityError and SetEntityFieldError to set the IDataErrorInfo interface values in the OnValidateFieldValue method.
((IDataErrorInfo)this).Error and ((IDataErrorInfo)this)["CatalogSection"] are both set correctly when OnValidateFieldValue exits, however, when control returns to SetNewFieldValue (in the generated code), ((IDataErrorInfo)this)["CatalogSection"] is an empty string, but ((IDataErrorInfo)this).Error still contains the value set in OnValidateFieldValue. I would expect both values to have remained as set.
protected override bool OnValidateFieldValue(int fieldIndex, object value)
{
if (((ProductFieldIndex)fieldIndex == ProductFieldIndex.CatalogSection) && (value.ToString().Trim().Length == 0))
{
SetEntityFieldError(((ProductFieldIndex)fieldIndex).ToString(),
"Catalog Section cannot be blank.",
false);
SetEntityError(((ProductFieldIndex)fieldIndex).ToString() + " cannot be blank.");
this.
}
return true;
}
It looks like the field value for IDataErrorInfo is being reset in the SetNewFieldValue method of EntityBase after OnValidateFieldValue is invoked.
Is this the expected behavior? Should I implement this another way? Perhaps by overriding the OnFieldValueChanged or in the EntityContentsChanged event handler?