LinqDataSourceUpdateEventArgs.OriginalObject Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the object that contains the values that were originally retrieved from the data source.
public:
property System::Object ^ OriginalObject { System::Object ^ get(); };
public object OriginalObject { get; }
member this.OriginalObject : obj
Public ReadOnly Property OriginalObject As Object
Property Value
An object of the type specified in the TableName property that contains the data that was retrieved from the data source.
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
You can use the OriginalObject property to check the original values against the current values in the data source and to cancel the update operation or take other action.
The OriginalObject property contains values for only the properties that are persisted in view state in the Web page. A property is persisted under these circumstances:
When it is displayed in a data-bound control.
When the ColumnAttribute.UpdateCheck property of the System.Data.Linq.Mapping.ColumnAttribute attribute is set to
Always
orWhenChanged
.
If the UpdateCheck property is set to Never
and the value is not displayed in a data-bound control, the value is not stored in the Web page. In that case, it cannot be assigned to the OriginalObject property.