FormView::ModeChanging Event


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Occurs when the FormView control switches between edit, insert, and read-only mode, but before the mode changes.

Namespace:   System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

event FormViewModeEventHandler^ ModeChanging {
	void add(FormViewModeEventHandler^ value);
	void remove(FormViewModeEventHandler^ value);

The ModeChanging event is raised when a 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 FormView control for a specific mode or canceling the mode change, whenever this event occurs.

A FormViewModeEventArgs object is passed to the event-handling method, which allows you to determine the mode to which the FormView control is switching, to determine whether the 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 NewMode property. You can also use the NewMode property to switch to an alternate mode by setting it to one of the FormViewMode enumeration values. Use the CancelingEdit property to determine whether the user canceled an edit operation. To cancel an insert operation, set the Cancel property to true.

For more information about handling events, see NIB: Consuming Events.

The following example demonstrates how to use the ModeChanging event to hide the pager row when the FormView control transitions to edit mode.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0
Return to top