ListView.InsertNewItem Method (Boolean)


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

Inserts the current record in the data source.

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

abstract InsertNewItem : 
        causesValidation:bool -> unit
override InsertNewItem : 
        causesValidation:bool -> unit


Type: System.Boolean

true to perform page validation when this method is called; otherwise, false.

Exception Condition

The ListView control does not have an insert item.


The DataSourceView object associated with the ListView control is null.

Use the InsertNewItem method to programmatically insert an item in the data source. This method is typically used to insert an item from outside the ListView control, such as from a different control on the page.

To use the InsertNewItem method, you must define an InsertItemTemplate template in the ListView control. You must also set the InsertItemPosition property to a value different from InsertItemPosition.None. To specify whether page validation is performed before the insert operation, use the causesValidation parameter.

This method raises the ItemInserted and ItemInserting events.

The following example shows how to use the InsertNewItem method to programmatically insert the contents of the insert item of a ListView control into the data source.

System_CAPS_security Security Note

This example has 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.

.NET Framework
Available since 3.5
Return to top