Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > DataForm > How to set the label for Validation errors?

Not answered How to set the label for Validation errors?

Feed from this thread
  • Jeff avatar

    Posted on Apr 19, 2012 (permalink)

    I have a RadDataForm with a number of DataFormDataField. They are bound to an object of a class that implements IDataErrorInfo, and when a field control validation, it's surrounded by a red box and an error message is displayed at the bottom of the form, prefixed by the DataFormDataField's label.

    I have three problems:

    1. What if the label I want to display in the form isn't the label I want to display with the error message?  I have a couple of controls where I want the label to include a closing colon, and that results in two colons in the error message.
    2. What if the control is not a DataFormDataField? The error message for these seems to display the name of the property it is bound to - and that's usually not what I want.
    3. I have added BindingGroups to a number of GroupBoxes on the form, that return errors if something about the group is wrong. (None of the fields in the group have been selected, etc.) These display an error message that just has a colon, with no label name at all.

    Seems like these are all different aspects of the same problem. Where does the form's error message display look, to get the names it includes, and how can I override this so as to use the labels I choose?

    Reply

  • Jeff avatar

    Posted on Apr 23, 2012 (permalink)

    Any ideas?  I'm lost.

    Reply

  • Say Hello to Telerik's PivotGrid for ASP.NET AJAX, Silverlight, WPF and WinForms. Now packed with OLAP support.
  • Ivan Ivanov Ivan Ivanov admin's avatar

    Posted on Apr 24, 2012 (permalink)

    Hi Jeff,

    Please excuse mo for the delayed answer. RadDataForm internally manages binding DataErrors and there is no easy way to make big changes in this mechanism. However, you can try disabling it. Basically it executes this logic on the BindingValidationError event, so that you can subscribe to it on DataFields' level and handle it there. Then you can implement your own custom validation errors like this:
    radDataForm.ValidationSummary.Errors.Add(...);
    Please, be advised that in case you choose this approach, you should also manage these errors removal from the validation summary. An alternative approach would be to retemplate the validation summary ItemTemplate, adding a converter that will generate the desired label names. As for the last point of your list, it will be great if you can send us a small project that illustrates your approach via a support ticket, so that we could debug it and implement a solution on our side. Please, do not hesitate to ask us for an example project if you have any difficulties while implementing the proposed approach, in case it meets your requirements.

    Greetings,
    Ivan Ivanov
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

    Reply

  • Nivin avatar

    Posted on Nov 1, 2012 (permalink)

    Hello Ivan,

    Could you please post some example code in which you have retemplated the validation summary ItemTemplate . 

    Thank you.

    Reply

  • Ivan Ivanov Ivan Ivanov admin's avatar

    Posted on Nov 6, 2012 (permalink)

    Hello Nivin,

    You can create a new ControlTemplate for DataFormValidationSummary and set it through RadDataForm's ValidationSummaryStyle property. In this ControlTemplate you can set a new ItemTemplate to the ItemsControl placed in the summary. Please, use the latest internal build, if possible, as we have fixed a related issue there.

    Kind regards,
    Ivan Ivanov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

    Reply

  • Say Hello to Telerik's PivotGrid for ASP.NET AJAX, Silverlight, WPF and WinForms. Now packed with OLAP support.

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > DataForm > How to set the label for Validation errors?