Hi,
I am using Telerik controls for silverlight 5 and Domain services.
I wanted to validate a filed against the database. I am using service method from the ViewModel to the validate that field.
As the Domain service is asynchronous, I am not able to set the error message to the RowEventArgs, once after the validation.
So I have implemented "INotifyDataErrorInfo" interfcae to notify the errors.
I am using "INotifyDataErrorInfo" in my ViewModel as below.
1) I have my DTO class in the server (EmployeeDTO in ther server project).
2) I am loading this object to the GridView through ViewModel.
3) In the "EmployeeDTO" I want to validate the "EmpId".
For this I have created following 2 properties in the ViewModel
a) CurrentItem (points to the seletedItem in the Grid)
b) EmpId (points to the EmpId of the currentItem)
public
EmployeeDTO CurrentItem
{
get
{
return
_currentItem; }
set
{ _currentItem = value; OnPropertyChanged(
"CurrentItem"
); }
}
public
string
EmpId
{
get
{
return
CurrentItem.EmpId; }
set
{
if
(CurrentItem.EmpId != value)
{
CurrentItem.EmpId = value;
OnPropertyChanged(
"EmpId"
);
}
}
}
4) I am validating this field in the RowValidating event and setting the error as below in the
operation_completed event of the Domain service.
AddErrorToPropertyAndNotifyErrorChanges(
"EmpId"
,
new
ValidationErrorInfo()
{ ErrorMessage =
"Should be Unique"
});
NotifyErrorsChanged(
"EmpId"
);
It is properly setting the error to that cell.
But the problem is, its not displaying the error when I add the error message to that property(in the Operation_Completed event).
This is displaying the error only when I go to that error field again.
I mean its not noifying the error automatically when the error is set.
Does GridViewCell has any issue displaying the error on notification?
Please help.
Regards,
SivaPrasad.B