The Navigating event and Adding a record


Author
Message
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.5K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
I am reacting to the Navigating event of a BO, to see if it is dirty and then allow the user to handle it if it is dirty. It appears to be raised AFTER the new row is added but before it is navigated to. The code I'm using in the Navigating event is:



If e.BusinessObject.IsDirty Then

' Confirm message

'...setup MessageItem so we can use MessageForm() to get result



Select Case MessageForm.ShowMessage(msgItem)

Case MessageFunctionType.Yes

e.BusinessObject.Save()

Case MessageFunctionType.No

e.BusinessObject.Undo(CurrentRowOnly)

Case MessageFunctionType.Cancel

' Cancel nav and any thing else to reset UI

e.Cancel = True

End Select







The problem is that when I click a button that calls the Add() method of the BO. This then calls the Navigating event handler (at some point) after the new record is added (which I guess makes sense). If the editing state of the BO is idle (not editing anything when Add() was called), the BO is dirty already. This then blows up because there is nothing to save or undo and canceling cancels the navigation to the new record! I'm not sure how to handle the case of a new record. Ideas?



I'm doing it this way because I have a listbox that allows the user to view all available records and navigate via the listbox.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search