NewObject Property
Collapse the table of content
Expand the table of content

LinqDataSourceInsertEventArgs.NewObject Property

Gets the object that contains the data to insert.

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

public Object NewObject { get; }

Property Value

Type: System.Object
An object that contains the data to insert.

The NewObject property contains the data that will be inserted into the data source. Create a handler for the Inserting event and retrieve the NewObject property in order to validate the data, change the data, or cancel the insert operation before the data operation is executed.

The NewObject property returns an object of type Object. You can cast this object to the type of the class that represents the data.

The following example shows a handler for the Inserting event. The object from the NewObject property is cast to a type named Product. The DateModified property of the Product object is set to the current date and time.


protected void LinqDataSource_Inserting(object sender, LinqDataSourceInsertEventArgs e)
{
    Product product = (Product)e.NewObject;
    product.DateModified = DateTime.Now;
}


.NET Framework

Supported in: 4, 3.5

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.

Community Additions

ADD
Show:
© 2016 Microsoft