datagridview exception handling

datagridview exception handling

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


nicolas posted on Tuesday, October 31, 2006

hello,

i'm trying to use editablerootlist in combination with datagridview. i want to save my row as soon as the row has been committed.
since i want to handle some concurrency issues i excluded AcceptChangesComplete to save in manually
i first tried to use the RowValidated event but this has some real wired behavior when you are using the newrow function of the grid. ( it gets called several times and the last time it gets called you can't access the databounditem since the item has been removed from the list.
then i tried to use AcceptChangesComplete again in the hope that i would be able to catch an exception which is thrown in the csla layer and relay the exception to the controller layer to handle it. sadly that wasn't the case.
does anyone have a appropriate practice since I'm not able to got anyhow in between the datagridviews and the editableroots endedit.

Bayu replied on Tuesday, October 31, 2006

Maybe it's a solution to make use of a BindingSource object. The datasource of this bindingsource is your BO, and you set the DataViews datasource to this bindingsource.

The thing is that the BindingSource throws several interesting events, among which the ListChanged Event. The ListChangedEventArgs that are supplied with it contains a property ListChangeType, you can base your logic on the value of this enumerated type.

Bayu

Copyright (c) Marimer LLC