This is a migrated thread and some comments may be shown as answers.

[Solved] Distinguish canceling in the ItemCreated event for FormTemplate

1 Answer 84 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Polaris431
Top achievements
Rank 1
Polaris431 asked on 15 Jun 2009, 03:47 PM
I have a FormTemplate with my own Update and Cancel buttons. When the user clicks on the Cancel button, the server-side ItemCreated event gets fired. Although firing this event might be part of the page life cycle, I still would like a way of knowing that the FormTemplate was canceled. If I cannot know that it is canceled, code within my ItemCreated event gets executed and I need to avoid this because certain controls during an edit would get set to a bound field but during a cancel, these fields are no longer available. But a more obvious reason I want to skip my code in the ItemCreated event is simply because it makes no sense to execute it when the FormTemplate is closing due to the Cancel button being pressed. Executing that code is wasted performance on the server-side. The IsInEditMode property returns true even when I cancel the FormTemplate, so I have no way of knowing whether I am in edit mode or cancel mode.

1 Answer, 1 is accepted

Sort by
0
Polaris431
Top achievements
Rank 1
answered on 15 Jun 2009, 04:12 PM
Problem solved. By moving my code to the ItemDataBound event (and out of the ItemCreated event), the IsInEditMode property will return false when the cancel button is pressed. This does not happen in the ItemCreated event.
Tags
Grid
Asked by
Polaris431
Top achievements
Rank 1
Answers by
Polaris431
Top achievements
Rank 1
Share this question
or