Problem setting the custom cell validation.

1 posts, 0 answers
  1. SivaPrasad Bevara
    SivaPrasad Bevara avatar
    73 posts
    Member since:
    Oct 2012

    Posted 08 Jun 2012 Link to this post


    I am using Telerik controls for Silverlight 5.

    I need to set the Unique key validation for a cell.

    On the "CellValidating" event, I am sending the cell value to the database and checking the value.

    Here the problem is with the asyncronous Domain service.

    I am using the MVVM architecture and Domain service. I have implemented the "CellValidating" event in the view model and in that event I am calling the service method as below.

    public void CellUniqueValidation(object obj)
                GridViewCellValidatingEventArgs e = (GridViewCellValidatingEventArgs)((Emps.ExtendedCommandParameter)(obj)).EventArgs;
                var currentColumn = e.Cell.Column as IDataGridColumn; //pointer to the cell's column
                if ((currentColumn != null)) //both are present 
                    var newData = e.NewValue == null ? "" : (e.NewValue).ToString(); //get the new value
                    var oldData = e.OldValue == null ? "" : (e.OldValue).ToString(); //get the old value
                        if (currentColumn.GridColumnIsUnique && newData != "")
                            _context.CheckUniqueness("Employee", "emp_id", operation =>
                               operation.Completed += new EventHandler(Uniqueness_operation_Completed);
                            }, null);
                            //e.ErrorMessage = "This is unique"; //set the error massage
                            //e.IsValid = false;

    And the opearation completed method is as below:
    void Uniqueness_operation_Completed(object sender, EventArgs e)
               if (((System.ServiceModel.DomainServices.Client.InvokeOperation<bool>)(sender)) != null)
                   if (((System.ServiceModel.DomainServices.Client.InvokeOperation<bool>)(sender)).Value)
                      //We can get the value here

    Here the problem is, we can know whether it is unique or not in the opration completed event,
    but there I cant set the error message as I cant access that cell there.
    How can I set the error message to that cell in the operation completed event.
    Or is there any way I can get the value from the domain service, in the CellValidating event itself.

    FYI: I am returning a scalar value from the domain service.

    Please help.

Back to Top