This documentation is archived and is not being maintained.

ListViewInsertEventArgs Class

Provides data for the ItemInserting event.

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

[AspNetHostingPermissionAttribute(SecurityAction::LinkDemand, Level = AspNetHostingPermissionLevel::Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction::InheritanceDemand, Level = AspNetHostingPermissionLevel::Minimal)]
public ref class ListViewInsertEventArgs : public CancelEventArgs

The ListView control raises the ItemInserting event when an Insert button in the control is clicked, but before the ListView control inserts the record. (An Insert button is a button whose CommandName property is set to "Insert".) This enables you to provide an event-handling method that performs a custom routine whenever this event occurs. For example, you can validate or HTML-encode the values of a record before it is inserted it in the data source.

A ListViewInsertEventArgs object is passed to the event-handling method. This object enables you to determine the value of an optional command argument that is sent to the ListView control. You can access the ListViewItem object that is being inserted by using the Item property. You can also read or modify the field values for the new record by using the Values property. To cancel the insert operation, set the Cancel property to true.

For a list of initial property values for an instance of the ListViewInsertEventArgs class, see the ListViewInsertEventArgs constructor.

The following example shows how to use the ListViewInsertEventArgs object to cancel an insert operation if the data item contains an empty value.

Security noteSecurity Note:

This example contains a text box that accepts 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.

System::Object
  System::EventArgs
    System.ComponentModel::CancelEventArgs
      System.Web.UI.WebControls::ListViewInsertEventArgs

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

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