LinqDataSourceInsertEventArgs.NewObject 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 data to insert.
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 that contains the data to insert.
Examples
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;
}
Protected Sub LinqDataSource_Inserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LinqDataSourceInsertEventArgs)
Dim product As Product
product = CType(e.NewObject, Product)
product.DateModified = DateTime.Now
End Sub
Remarks
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.