I have a RadGrid that takes data from a business object of some sort. I use the Microsoft Enterprise Library 4.1 to conduct validation on the object by decorating with a [HasValidation] attribute and handling accordingly.
I'm having problems working out how to just pass back validation errors without ending the insert / update process. I'll elaborate.
For:
OnUpdateCommand="TelerikGrid_OnUpdateCommand"
I have:
protected
void
TelerikGrid_OnUpdateCommand(
object
source, GridCommandEventArgs e)
{
this
.businessObject =
new
BusinessObject();
this
.businessObject.GetGridValues(e);
var validationResults = Validation.Validate(
this
.businessObject);
if
(validationResults.IsValid)
{
this
.businessObjectData =
new
BusinessObjectData();
int
updateResult =
this
.businessObjectData.Update(
this
.businessObject);
switch
(updateResult)
{
case
-1:
this
.Master.FeedbackText =
"Not updated."
;
break
;
default
:
this
.Master.FeedbackText =
"Updated."
;
break
;
}
}
else
{
this
.Master.FeedbackText =
string
.Format(
"Errors found in submission: {0}"
,
ValidationHelper.GetErrors(validationResults,
false
));
}
}
Everything works very well but if there are validation errors, the errors are displayed but the grid appears to rebind, collapsing the edit form and losing all the entered values in the process.
How can I retain the values entered and stop the edit form collapsing when the data fails validation?
Regards,
Richard