IsDirty not getting set on bound object

IsDirty not getting set on bound object

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


DanEssin posted on Tuesday, July 18, 2006

I have a business object (root) that is connected to a binding source and a number of controls reference the binding source. Some of the controls are combos with lists that are bound to other bo's, some are text boxes and some are text boxes that are populated by clicking buttons on the form that set the Text property of the controls.

Typing in the textboxes causes IsDirty on the Root BO to become true however, choosing an item in a combo does not and setting the Text property in code does not.

I don't know enough about the internals of binding to have any idea how to diagnose this problem.

Any pointers would be appreciated.

RockfordLhotka replied on Tuesday, July 18, 2006

I don't think combobox controls update the data source until the user tabs out of the control. Just choosing an item doesn't cause the control to emit the data field.

I don't know about the Text property thing - but I'm betting that it isn't putting the value in the object because the SelectedIndex isn't changing, though I don't know for sure.

Your problem isn't that IsDirty isn't being set - it is that the value isn't being emitted from the control back into data binding. ComboBox controls are (imo) a PITA in this regard (as are the calendar and timepicker controls).

To help you debug, you might put Debug.WriteLine() statements in your property set block. Or a debugger breakpoint. Then you can watch to see when (if) the value is sent from the control to the object.

DanEssin replied on Tuesday, July 18, 2006

Thanks for the suggestion. It's pretty clear that the values aren't
getting sent to the BO and that it's all the result of how the controls
behave. I guess that I'll just have to beat on it some more - or change
from MS controls to some others.


RockfordLhotka wrote:
>
> I don't think combobox controls update the data source until the user
> tabs out of the control. Just choosing an item doesn't cause the
> control to emit the data field.
>
> I don't know about the Text property thing - but I'm betting that it
> isn't putting the value in the object because the SelectedIndex isn't
> changing, though I don't know for sure.
>
> Your problem isn't that IsDirty isn't being set - it is that the value
> isn't being emitted from the control back into data binding. ComboBox
> controls are (imo) a PITA in this regard (as are the calendar and
> timepicker controls).
>
> To help you debug, you might put Debug.WriteLine() statements in your
> property set block. Or a debugger breakpoint. Then you can watch to
> see when (if) the value is sent from the control to the object.
>
>
>
>

Michael Hildner replied on Tuesday, July 18, 2006

I also ran into setting the .Text property in code didn't work, so I set the text through the business object.

Mike

DanEssin replied on Tuesday, July 18, 2006

I tried that but it didn't update the screen. How did you avoid that?

Thanks,
de

On Tue, 18 Jul 2006 16:42:31 -0500, "Michael Hildner"
said:
> I also ran into setting the .Text property in code didn't work, so I set
> the text through the business object.
>
> Mike
>
>

Michael Hildner replied on Tuesday, July 18, 2006

Maybe I just got lucky? I have no idea, but it works. I have code like this:

this._orderHeader.Customer.LastName = "Presley";

_orderHeader is a business object and Customer is a property of the _orderHeader class, which is also a business object. I am setting stuff through the properties, not sure if that would make a difference.

Regards,

Mike

DanEssin replied on Tuesday, July 18, 2006

I'll try it again. Maybe I'll get lucky too :)
Thanks,
de

On Tue, 18 Jul 2006 17:04:28 -0500, "Michael Hildner"
said:
> Maybe I just got lucky? I have no idea, but it works. I have code like
> this:
>
> this._orderHeader.Customer.LastName = "Presley";
>
> _orderHeader is a business object and Customer is a property of the
> _orderHeader class, which is also a business object. I am setting stuff
> through the properties, not sure if that would make a difference.
>
> Regards,
>
> Mike
>
>

Copyright (c) Marimer LLC