ListView::ItemInserting Event

 
System_CAPS_noteNote

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

Occurs when an insert operation is requested, but before the ListView control performs the insert.

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

public:
event EventHandler<ListViewInsertEventArgs^>^ ItemInserting {
	void add(EventHandler<ListViewInsertEventArgs^>^ value);
	void remove(EventHandler<ListViewInsertEventArgs^>^ value);
}

The ListView control raises the ItemInserting 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 NIB: Consuming Events.

The following example shows how to add an event handler for the ItemInserting event.

System_CAPS_security Security Note

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.

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

.NET Framework
Available since 3.5
Return to top
Show: