System.Web.UI.WebControls.FormView.ItemInserted Event

Occurs when an Insert button within a System.Web.UI.WebControls.FormView control is clicked, but after the insert operation.


public event FormViewInsertedEventHandler ItemInserted


The System.Web.UI.WebControls.FormView control raises the FormView.ItemInserted event when an Insert button (a button with its CommandName property set to "Insert") within the control is clicked, but after the System.Web.UI.WebControls.FormView control inserts the record. This allows you to provide an event-handling method that performs a custom routine, such as checking the results of an insert operation, whenever this event occurs.

A System.Web.UI.WebControls.FormViewInsertedEventArgs object is passed to the event-handling method, which allows you to determine the number of records affected and any exceptions that might have occurred. To determine the number of records affected by the insert operation, use the FormViewInsertedEventArgs.AffectedRows property. Use the FormViewInsertedEventArgs.Exception property to determine whether any exceptions occurred. You can also indicate whether the exception was handled in the event-handling method by setting the FormViewInsertedEventArgs.ExceptionHandled property. If you need to access the values of the inserted record, use the FormViewInsertedEventArgs.Values property.

By default, the System.Web.UI.WebControls.FormView control returns to the mode specified by the FormView.DefaultMode property after an insert operation. To keep the System.Web.UI.WebControls.FormView control in insert mode, set the FormViewInsertedEventArgs.KeepInInsertMode property to true.

For more information about handling events, see Consuming Events.


Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions:
Since: .NET 2.0