How to 'Auto Save' after an edit and scrolling to a new row


Author
Message
Peter Jones
Peter Jones
Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)
Group: Forum Members
Posts: 386, Visits: 2.1K

I'm having problems working my way through this issue and I was hoping you could provide a code snippet/advice to show me how I handling this function correctly. I'm using a DevExpress grid and want to auto save any changes as the user moves between rows. To do this I have the following code in the BO:

Private Sub boATT_Navigating(ByVal e As MicroFour.StrataFrame.Business.NavigatingEventArgs) Handles Me.Navigating
   If Me.IsDirty Then
      Me.Save()
   End If
End Sub

This works fine until I add a new record. Then, for some reason, IsDirty is True (when it shouldn't be) and Save executes. The problem is boATT_Navigating keeps getting fired and, because IsDirty is still true, Save executes again and eventually I get a stack overflow on the Save.

I tried (and failed) to find a property that tells me I'm entering 'create a new record' mode. I thought I could add that test to the IsDirty so I don't execute the Save when starting the create new record cycle.

I'm not setting any default values so that isn't the cause if IsDirty being true.

Even though Save is firing no SQL update code is being executed.

Cheers, Peter

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Then, for some reason, IsDirty is True (when it shouldn't be) and Save executes.

This is by design and is correct.  IsDirty actually looks to see if there are any records within the CurrentDataTable that have been modified, deleted, or added.  So IsDirty is indicating that you have added a record.

I think that you would be better of doing one of two things.  Since you are using a grid, and grids are a different animal than any other type of control due to the massive amount of code behind a grid, events may behave slightly different.  You should try capturing an event on the grid that indicates that the row has already been navigated...or, try placing your code in the Navigated event rather than the Navigating.  This is why your Add behaves the way it does....the navigation to the new row has not yet taken place.

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Testing, please ignore Smile
Attachments
DDT.jpg (89 views, 7.00 KB)
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search