This documentation is archived and is not being maintained.

LinqDataSourceUpdateEventArgs.NewObject Property

Gets the object that contains the values that will be saved in the data source.

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 of the type specified in the TableName property that contains the data to save.

Create an event handler for the Updating event and retrieve the NewObject property to validate the data. You can also change the data or cancel the update operation.

The following example shows an event handler for the Updating event. The example shows how to compare properties from the OriginalObject property and the NewObject property to determine whether the value in the Category property has changed. If so, the CategoryChanged property of the object in the NewObject property is set to true.


protected void LinqDataSource_Updating(object sender, LinqDataSourceUpdateEventArgs e)
{
    Product originalProduct = (Product)e.OriginalObject;
    Product newProduct = (Product)e.NewObject;

    if (originalProduct.Category != newProduct.Category)
    {
        newProduct.CategoryChanged = true;
    }
}


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