Επεξεργασία

Κοινή χρήση μέσω


LinqDataSourceUpdateEventArgs.NewObject Property

Definition

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

public:
 property System::Object ^ NewObject { System::Object ^ get(); };
public object NewObject { get; }
member this.NewObject : obj
Public ReadOnly Property NewObject As Object

Property Value

An object of the type specified in the TableName property that contains the data to save.

Examples

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;
    }
}
Protected Sub LinqDataSource_Updating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LinqDataSourceUpdateEventArgs)
    Dim originalProduct As Product
    Dim newProduct As Product

    originalProduct = CType(e.OriginalObject, Product)
    newProduct = CType(e.NewObject, Product)

    If (originalProduct.Category <> newProduct.Category) Then
        newProduct.CategoryChanged = True
    End If
End Sub

Remarks

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.

Applies to