DataBinding, IDataErrorInfo and datatype validation

DataBinding, IDataErrorInfo and datatype validation

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


SoftwareArchitect posted on Wednesday, May 17, 2006

I have a windows form with a textbox bound to a decimal property (registration cost) of my business object.  If I set the text to "abc", control gets locked onto the textbox and I do NOT get an error from my errorprovider control.

I realize that since BusinessBase implements IDataErrorInfo and is returning the string in the Item property based on the validation rules...that somehow the native error of "input is in an invalid format" is getting lost. 

This has got to be simple...someone tell me I can get the original databinding error.  I don't know how I can check the datatype when the property set procedure is never even being entered.

Thanks much,
Mike

razorkai replied on Wednesday, May 17, 2006

Hi Mike.

Sounds like the following article may help you....

http://www.lhotka.net/Articles.aspx?id=54b7097e-2eb5-476d-842b-98fde95c2006

HTH

John.

SoftwareArchitect replied on Thursday, May 18, 2006

Thanks John.  That is exactly what I needed.

esteban404 replied on Thursday, May 18, 2006

I sent that article to my Third Party control developer in regard to databinding a CSLA 1.52 object's field of type byte[] (image in the MS SQL database). Everything works, but the fix Rocky lists won't work with my DevExpress  pictureEdit control. I've worked around it, but I imagine it'd be the same for some other controls.

What I had to do was catch an invalid cast exception and not do anything in the EditValueChanged event rather than handle it in the databinding. Really not good, but it does work. Same problem for null SmartDates using one of their controls, but that one is handled by the object set accessor instead of the Winform.

_E

SoftwareArchitect replied on Thursday, May 18, 2006

Here is a problem related to the solution in the article -

if you use the BindingSourceRefresh control then the Me.ValidateChildren will NOT be set to false indicating that the controls are valid.  I am not sure why this is...I just know when I disable that control the solution in the article works.

Rocky - didn't know if you wanted to make a note of this in the article (in your spare time..ha ha).

SoftwareArchitect replied on Thursday, May 18, 2006

esteban404:

I sent that article to my Third Party control developer in regard to databinding a CSLA 1.52 object's field of type byte[] (image in the MS SQL database). Everything works, but the fix Rocky lists won't work with my DevExpress  pictureEdit control. I've worked around it, but I imagine it'd be the same for some other controls.

What I had to do was catch an invalid cast exception and not do anything in the EditValueChanged event rather than handle it in the databinding. Really not good, but it does work. Same problem for null SmartDates using one of their controls, but that one is handled by the object set accessor instead of the Winform.

_E



I am not sure I understand....where is the EditValueChanged event?  I am assuming on the winform side?  So, that specific control is not using databinding at all?

Thanks,
Mike

Copyright (c) Marimer LLC