DataGridViewTextBoxColumn initially showing Csla.Validation.CommonRules.StringRequired is broken

DataGridViewTextBoxColumn initially showing Csla.Validation.CommonRules.StringRequired is broken

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


dlabar posted on Tuesday, December 04, 2007

I've bound two properties of a CSLA.BusinessListBase BO to a DataGridView.  When the form loads, the data is displayed, but it is showing that Csla.Validation.CommonRules.StringRequired has been broken, even though those properties of the object have values. 

If I select a different value from the DataGridViewTextBox, the broken rule goes away, never to return, even if I select the original value.  What am I doing wrong?

It must be something with the validation rules being performed on an object other than the one that is databound to the grid.  Anyone have any ideas?

JoeFallon1 replied on Wednesday, December 05, 2007

When you fetch the BO your last line of code is usually:

ValidationRules.CheckRules()

This way the BO is returned to you in its correct state initially.

As you set each property you should call PropertyHasChanged("PropName") to re-evaluate the rules.

Sounds like you night have things out of sequence and that setting the property in the grid unbreaks the rule correctly.

Joe

dlabar replied on Wednesday, December 05, 2007

Thanks so much, I just assumed that the Datagridview was causing my propblem, but after your post, I checked for any broken rules directly after my fetch, and sure enough before I even bound it to anything, I had broken rules.

Therefore I knew, somewhere ValidationRules.CheckRules wasn't being called.  I checked the Fetch statement, and it was being called there.  Then I remembered that I make a copy of the object after I fetch it.  When I copied the object, I didn't use the properties, I used the private variables, and therefore needed to call ValidationRules.CheckRules after the copy was made.  Once I added this, everything worked great.

 

Thanks!

Copyright (c) Marimer LLC