Export (0) Print
Expand All
0 out of 2 rated this helpful - Rate this topic

ListView::ItemInserting Event

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);
}
<asp:ListView OnItemInserting="EventHandler" />

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 Consuming Events.

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

Security noteSecurity 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.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

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

.NET Framework

Supported in: 3.5
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.