I’m frustrated

Validate Messages are not displaying on "DataSheet" view.

I am using "DataSheet" view to display "orderLine" table data. I am performing validation on some of the fields & trying to show validation message in front of those fields. I tried using below three methods- ShowAlert(),ShowMessage(),ExecuteOnClient().but messages are not getting displayed on UI.

//Result.ShowAlert("Discount Amount should not be greater than Line Total.", "DiscountAmount");
//this.Result.ExecuteOnClient("this._focus('DiscountAmount',' " + "Discount Amount should not be greater than Line Total." + "');");

Result.ShowMessage("Discount Amount should not be greater than Line Total");

In Firebug, I can see the ClientScript property loaded with Javascript as "Web.DataView.showMessage('Discount Amount should not be greater than Line Total'); , but it is not executing in browser. Please assist on this ASAP
1 person has
this problem
+1
Reply
  • Please post the entire validation business rule method to help us understand your validation process.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated indifferent, undecided, unconcerned kidding, amused, unsure, silly happy, confident, thankful, excited

  • I have created "UpdateOrderLine()" method, which is calling "ValidateView()" for validation before update orderline in database. "ValidateView" contains validation business rules. I have observed that these rules perform well on Form type View lime - "editForm1" View, but doesnt works with "Datasheet" view.

    [ControllerAction("OrderLines", "Update", ActionPhase.Before)]
    protected void UpdateOrderLine()
    {
    orderManager = new OrderManagement();
    OrderLines orderLine = new OrderLines();
    //Read line submitted from the browser
    orderLine = Arguments.ToObject();
    orderLine.LineTotal = orderLine.LineTotalCalculated;

    //Prevent COTS default action & assign modified values
    PreventDefault();

    if(this.ValidateView(orderLine,this.Arguments.View))
    {
    //further processing
    }
    }

    protected bool ValidateView(OrderLines orderLine, string viewId)
    {
    bool isValid = true;
    if (viewId.Equals("grid1", StringComparison.OrdinalIgnoreCase) ||
    viewId.Equals("createForm1", StringComparison.OrdinalIgnoreCase) || viewId.Equals("editForm1", StringComparison.OrdinalIgnoreCase))
    {
    if (orderLine.Qty == null || orderLine.Qty < 1)
    {
    isValid = false;
    Result.ShowAlert("Quantity must be greater than zero.", "Qty");
    return isValid;
    }
    if (orderLine.UnitPrice == null || orderLine.UnitPrice < 0)
    {
    isValid = false;
    Result.ShowAlert("UnitPrice must be greater than zero.", "UnitPrice");
    return isValid;
    }
    if (orderLine.DiscountId > 0)
    if (orderLine.DiscountAmount 0)
    if (orderLine.DiscountId 0))
    {
    isValid = false;
    Result.ShowAlert("Discount Amount should not be greater than Line Total.", "DiscountAmount");
    //this.Result.ExecuteOnClient("this._focus('DiscountAmount',' " + "Discount Amount should not be greater than Line Total." + "');");

    //Result.ShowMessage("Discount Amount should not be greater than Line Total");

    return isValid;
    }
    }
    return isValid;
    }
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated indifferent, undecided, unconcerned kidding, amused, unsure, silly happy, confident, thankful, excited

  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated indifferent, undecided, unconcerned kidding, amused, unsure, silly happy, confident, thankful, excited

  • The fix will be deployed in the update on Wednesday
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated kidding, amused, unsure, silly happy, confident, thankful, excited indifferent, undecided, unconcerned