How do you update business base object columns attached on winforms binding source through code?

How do you update business base object columns attached on winforms binding source through code?

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


GeorgeG posted on Friday, October 12, 2007

I have an ERLB that is bound with a windows binding source. The user wants to put a default value on a textbox not attached anywhere and click a button and update the current row with all the rates with that default rate.
This is what I currently do
decimal rate = Convert.ToDecimal( textBoxRateOverride.Text );
Destination currentDestination = (Destination)destinationsBindingSource.Current;
currentDestination.rate_a = rate;
currentDestination.rate_b = rate;
currentDestination.rate_c = rate;
this.destinationsBindingSource.RaiseListChangedEvents = true;
which works.

Is this an acceptable way?

Thanks

Marjon1 replied on Saturday, October 13, 2007

The only thing that I would contemplate doing is putting a method on the ERLB that takes the rate and applies it to all items within itself, this would then remove the responsibility from the UI designer to have to do apply the correct rate to the each item. You could then stop the list changing events from within that method and the UI designer would only need to worry about getting the rate and calling your method.

Anyone else got an opinon? I'm still getting my head around alot of this stuff.

GeorgeG replied on Tuesday, October 16, 2007

You are right. Doing it on the business object makes more sense.

Thanks

 

Copyright (c) Marimer LLC