Occurs when an insert operation is requested, but before the ListView control performs the insert.
Assembly: System.Web.Extensions (in System.Web.Extensions.dll)
The ListView control raises the event when an Insert button in the InsertItemTemplate template is clicked or the InsertNewItem method is called, but before the ListView control inserts the record. (An Insert button is a button control whose CommandName property is set to "Insert".) This enables you to perform a custom routine whenever this event occurs, such as HTML-encoding the values of a record before it is inserted in the data source.
A ListViewInsertEventArgs object is passed to the event handler, which enables you to determine the value of an optional command argument sent to the ListView control. It also lets you indicate that the insert operation should be canceled. To cancel the insert operation, set the Cancel property to true. You can read or modify the field values for the new record by using the Values property.
For more information about how to handle events, see Consuming Events.
The following example shows how to add an event handler for the event.
This example contains controls that accept user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see Script Exploits Overview.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, 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.