Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7641685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:59:13+00:00 2026-05-31T08:59:13+00:00

I am experiencing issued performing validation from the codebehind. My data is displayed in

  • 0

I am experiencing issued performing validation from the codebehind. My data is displayed in a datagrid. One of the columns (type) is a drop down and when the drop down menu is changed it triggers a DropDownClosed Event which is handled in the code behind.

What I am trying to achieve is to validate the content of the following column to match the newly selected type in the drop down. If it does not match i want a validation error to be displayed on the grid. I implemented my validation using the INotifyDataErrorInfo interface and it works really well except when I use it in the code behind. When the code behind calls the validation the ValidationSummary of the datagrid is never updated. What I am doing wrong here ??? When using the debugger I can clearly see the errors being added to the Errors dictionnary of the interface…

Here is the handler:

        private void TypeBoxChanged(object sender, EventArgs e)
        {
        ComboBox box = (sender as ComboBox);
        IncomingPolicy row = (IncomingPolicy)box.DataContext;

        string ruleTypeValue = TypeList.GetKeyForText(box.SelectedItem.ToString());
        //check if the type is the same
        if(row.TypeWrapper == ruleTypeValue)
            return;
        if (row.ValidateRule(ruleTypeValue))
        {
            //SAVE the record
        }
        else
        {
            row.RaiseErrorsChanged("RuleWrapper");
        }
    }

The validate rule method will based on the ruletypevalue call this method

        public bool ValidateRegularExpression(string property, string value, string expression, string errorMessage)
        {
        bool isValid = true;
        Regex regex = new Regex(expression);
        Match match = regex.Match(value);
        if (match.Success)
        {
            RemoveError(property, errorMessage);                
        }
        else
        {
            AddError(property, errorMessage, false);
            isValid = false;
        }

        return isValid;
    }

I followed the sample implementation on MSDN http://msdn.microsoft.com/en-us/library/system.componentmodel.inotifydataerrorinfo%28VS.95%29.aspx

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T08:59:14+00:00Added an answer on May 31, 2026 at 8:59 am

    Some time earlier I’ve implemented validation helpers and created the sample solution for both interfaces IDataErrorInfo and INotifyDataErrorInfo:

    http://vortexwolf.wordpress.com/2011/10/01/wpf-validation-with-idataerrorinfo/

    Source code

    The main implementation is here:

    this.PropertyChanged += (s, e) => 
    {
        // if the changed property is one of the properties which require validation
        if (this._validator.PropertyNames.Contains(e.PropertyName))
        {
            this._validator.ValidateProperty(e.PropertyName);
            OnErrorsChanged(e.PropertyName);
        }
    }
    

    You should always call the OnErrorsChanged (or RaiseErrorsChanged in your case) method regardless of success of validation: if the property is invalid – the red border will be displayed, if it is valid – the bound control will be returned to its normal state.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am experiencing issues with deleting a row / data record from an SQLite
Am I the only one experiencing this issue? I'm using the html5media library and
I am experiencing issues with existing projects from Netbeans 6.5 in Netbeans 6.7 when
I am experiencing several issues that I can't understand from the first glances. The
I really need some help with Plone. I am experiencing some issue upgrading from
I'm experiencing an issue on a test machine running Red Hat Linux (kernel version
I'm experiencing an issue with ActiveMQ and would like to trace/view all ActiveMQ activity.
I am experiencing an issue with v1 of Ninject and resetting the StandardKernel. I
I have an XP client that is experiencing an issue. My dev box is
Wanting to implement authentication by client certificates I am experiencing some issues. First some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.