ValidationRules not getting triggered

ValidationRules not getting triggered

Old forum URL: forums.lhotka.net/forums/t/4405.aspx


meierk posted on Monday, February 25, 2008

I have a form that has parent -> child -> grandchild data displayed through common winform controls, including 2 grids.

Parent is a BusinessBase
Child is a BusinessListBase
Grandchild is a BusinesListBase

My form is setup as follows:

On Form_Load, I call a methed to get my data.  The populates the parent and child.  The grandchild is populated in the _PositionChanged event of the child datasource.  Immediately after acquiring the data for the parent and child, I bind the objects to the binding sources and set the binding source RaiseListChangedEvents = true.  This was basically copied from the Project Tracker sample application.

Problem:

For both the child and grandchild, my ValidationRules fire properly and I get the round red icon next to the control that is in error.  However, the rules never fire for the parent and I am always able to save invalid data

Unfortunately, this application is now in user acceptance test so I need to resolve asap.  This is my last issue to resolve and I will have deployed my first CSLA application to production.

Any ideas, thoughts, steps to track down?

Thx,
Kevin





RockfordLhotka replied on Monday, February 25, 2008

When you say "the rules never fire" for the parent, you mean that the rules never execute in the business object itself? So the object never goes into an invalid state?

Or just that the broken rules don't appear in the UI? In which case the user should get a ValidationException when they try to save the objec.

meierk replied on Monday, February 25, 2008

After removng my custom validation directly in the form, I can see that the ValidationRules DO execute in the business object so it appears the problem is that the broken rules simply don't work in the UI.

Thanks Rocky, this gives me any "search" parameter....  I never even thought to search for Broken Rules :)

Kevin

meierk replied on Monday, February 25, 2008

I just traced through the code and the ValidationRules are definitely getting invoked, I just don't get the red icon notification in the UI.

Thx,
Kevin

triplea replied on Monday, February 25, 2008

By the way when you say the parent is invalid do you mean that a property (or a rule specific to the parent) is invalid or that the parent is invalid because even though all its properties are fine, its children are invalid?

I just now encountered a scenario with a master/detail grid where some of my children are invalid (thus making the parent invalid to me as far as I am concerned) and the red exclamation mark only appears when the invalid children are shown. But never on the parent record... I kind of think that's the problem you are facing... If so I would be interested in a solution Smile [:)]

RockfordLhotka replied on Monday, February 25, 2008

If the object’s rules are running and you just aren’t seeing the results in the UI then you probably have your ErrorProvider set up wrong.

 

You need on ErrorProvider per object or bindingsource (so a different one for the parent and child or whatever) but you don’t need one for data in a grid (because the grid does this itself).

 

Rocky

meierk replied on Monday, February 25, 2008

Thanks Rocky.  I added an errorprovider for the parent binding source and I now get the error icon.

Although I understand that data grids may set the error provider automatically, I still don't understand why this affecting this form, but yet I have another form (with the same 3 binding sources) with numerous TextBox components bound to properties in my Child object and the icons show up fine without using an error provider.

Can you shed any light on this?

Kevin

Copyright (c) Marimer LLC