Occurs when the System.Web.UI.WebControls.FormView control switches between edit, insert, and read-only mode, but before the mode changes.
The FormView.ModeChanging event is raised when a System.Web.UI.WebControls.FormView control attempts to switch between edit, insert, and read-only mode, but before the mode actually changes. This allows you to provide an event-handling method that performs a custom routine, such as configuring the System.Web.UI.WebControls.FormView control for a specific mode or canceling the mode change, whenever this event occurs.
A System.Web.UI.WebControls.FormViewModeEventArgs object is passed to the event-handling method, which allows you to determine the mode to which the System.Web.UI.WebControls.FormView control is switching, to determine whether the FormView.ModeChanging event was raised as a result of the user canceling an edit operation, or to indicate that an insert operation should be canceled. To determine the new mode, use the FormViewModeEventArgs.NewMode property. You can also use the FormViewModeEventArgs.NewMode property to switch to an alternate mode by setting it to one of the System.Web.UI.WebControls.FormViewMode enumeration values. Use the FormViewModeEventArgs.CancelingEdit property to determine whether the user canceled an edit operation. To cancel an insert operation, set the System.ComponentModel.CancelEventArgs.Cancel property to true.
For more information about handling events, see Consuming Events.