ERLB and CSLAActionExtender, ArgumentOutOfRangeException after Save

ERLB and CSLAActionExtender, ArgumentOutOfRangeException after Save

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


bignick posted on Monday, May 11, 2009

I have a Customer class that is a BB.  The Customer has a collection of contacts that are updated indvidually from a separate modal form.  The ContactList is an EditableRootListBase<Contact>. 

I have a form with a CslaActionExtender, when I open the form and call customerExtender.ResetActionBehaviors(_customer);  it ends up calling SaveItem on my ContactList.  This isn't a problem on the open, although I don't know why it needs to do that the first time I bind.  The problem happens when I save my customer.  It get's through the DataPortal_Update just fine, but in the ActionExtender when it tries to rebind after save, it again tries to call SaveItem on my ContactList.  This time it passes in one of the contacts, and for some reason it returns -1 for the index.  Then it tries to access that index and throws the exception.

If anyone has any idea why it needs to call SaveItem when I bind or has an idea of how to prevent this error I'd greatly appreciate any help.

RockfordLhotka replied on Monday, May 11, 2009

Are you unbinding the item before showing it in the modal dialog?

Windows Forms data binding doesn't like it when one object is being managed by more than one bindingsource. So if your object (even indirectly through the list) is being managed by the bindingsource on one form, and then again by a bindingsource on the modal form, you'll have trouble.

Copyright (c) Marimer LLC