ASP.Net, GridViews, LLBLGenProDataSource2, Cancel Perform Work

Posts   
 
    
caseyry
User
Posts: 79
Joined: 25-Feb-2005
# Posted on: 24-Jun-2007 22:49:28   

Basics: LLBLGen version 2.0.07.0424, C#, .net 2.0, Adapter

We've run into some complications using Adapter, GridViews and LLBLGenProdDataSource2 with live persistence set to false.

What we want to do is validate the changes made to an entity in the GridView using a business object.

In the LLBLGenProDataSource2 PerformWork event handler, we create a business object and if it fails validation, append an error message to the validation summary. The problem with doing this is that the GridView re-binds itself, and the data the user entered is gone. Is there a way to "cancel" the PerformWork event?

Alternatively, I tried doing the validation in the GridView's RowUpdating event, but, at that point the datasource doesn't have any of the changes that were made by the user. The RowUpdating event args does have a NewValues dictionary, but stuffing those values into an entity doesn't appear to be straightforward.

The current solution we have is to create asp.net validators that fire and prevent the GridView's RowUpdating event from firing, since the page isn't valid. An alternative, which I'm not fond of, is to throw an exception in the PerformWork event handler.

Do you all have any suggestions for handling validation with GridViews and the LLBLGenProDataSource2 classes?

Thanks.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 25-Jun-2007 06:46:56   

Seems to me that if you don't change the underlaying collection of the LLBLGenDataSource the GridView should remains the same. Could you post some code (PerformWork event) and declarative aspx of your GridView and LLBLGenDataSource?

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39912
Joined: 17-Aug-2003
# Posted on: 25-Jun-2007 09:30:01   

Please check out v2.5 beta, which has new events: ExecuteInserting/Deleting/Updating which are cancelable.

Frans Bouma | Lead developer LLBLGen Pro
caseyry
User
Posts: 79
Joined: 25-Feb-2005
# Posted on: 25-Jun-2007 15:29:51   

daelmo wrote:

Seems to me that if you don't change the underlaying collection of the LLBLGenDataSource the GridView should remains the same.

I don't change the underlying collection via code, but the GridView does "push" the changes the user made to the LLBLGenDataSource so that when the PerformWork event fires, the collection reflects the changes made by the user.

Frans, I'll check out the beta. Thanks for the heads up.

-Ryan Casey

caseyry
User
Posts: 79
Joined: 25-Feb-2005
# Posted on: 27-Jun-2007 20:31:00   

Otis wrote:

Please check out v2.5 beta, which has new events: ExecuteInserting/Deleting/Updating which are cancelable.

The new events work very well, thanks!