StrataFrame Forum

RowChanged event handler removed after Clear

http://forum.strataframe.net/Topic13050.aspx

By MarcoR - 12/15/2007

I register a CurrentDataTable.RowChanged event handler during initialization. After a call to the Clear method I notice it is no longer called. Is there a better event to hook into for the same notification that carries across the CurrentDataTable being renewed?
By Greg McGuffey - 12/16/2007

I believe there is an event fired by BOs when the data table is loaded (can't remember the name of it at the moment). You might try setting the row changed event handler there. That way it would be reset whenever it is reloaded.
By StrataFrame Team - 12/17/2007

Yes, you will want to add a handler to the CurrentDataTableRefilled event as well and inside of that handler, remove the RowChanged handler from the old DataTable and add it to the new CurrentDataTable (you'll need to store off a reference to the DataTable you've attached to so that you can remove the handler from it).  When you refill a business object, the old object is disposed and a new DataTable is created, so your event handler it attached to the "dead" DataTable, not the live one.  So, add the handler initially, just like you're doing now, but also add a handler to the CurrentDataTableRefilled event on the same business object and when it's fired, remove the old RowChanged handler and add a new one.

FYI, you might want to look into attaching to the CurrentDataTable.DefaultView.ListChanged event.  It tells you almost everything that the RowChanged event does, but it also tells you what column changed when a new value is set on a field.

By MarcoR - 12/17/2007

Thanks! I had a temporary fix using a

new public void Clear()

, but this is much cleaner (and also works when cast to the base class Smile ).