This documentation is archived and is not being maintained.

FormView::ModeChanging Event

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);
<asp:FormView OnModeChanging="FormViewModeEventHandler" />

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 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

Supported in: 4, 3.5, 3.0, 2.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.