LinqDataSourceDeleteEventArgs.OriginalObject 属性
定义
获取表示要删除数据的对象。Gets the object that represents the data to delete.
public:
property System::Object ^ OriginalObject { System::Object ^ get(); };
public object OriginalObject { get; }
member this.OriginalObject : obj
Public ReadOnly Property OriginalObject As Object
属性值
具有 TableName 属性中指定类型的对象,该对象包含要删除的数据。An object of the type specified in the TableName property that contains the data to delete.
示例
下面的示例演示如何根据属性中的属性和网页中的值取消删除操作 OriginalObject 。The following example shows how to cancel the delete operation based on a property in the OriginalObject property and a value from the Web page. 在此示例中,用户必须选择一个 CheckBox 控件,以便在其 OnSale 属性设置为时确认是否要删除该产品记录 true 。In the example, users must select a CheckBox control to confirm that they want to delete a product record when its OnSale property is set to true.
protected void LinqDataSource_Deleting(object sender, LinqDataSourceDeleteEventArgs e)
{
Product product = (Product)e.OriginalObject;
if (product.OnSale && !confirmCheckBox.Checked)
{
e.Cancel = true;
}
}
Protected Sub LinqDataSource_Deleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LinqDataSourceDeleteEventArgs)
Dim product As Product
product = CType(e.OriginalObject, Product)
If (product.OnSale And Not confirmCheckBox.Checked) Then
e.Cancel = True
End If
End Sub
注解
在 OriginalObject 删除数据之前,可以使用属性与数据进行交互。You can use the OriginalObject property to interact with the data before it is deleted. 您可以验证数据,也可以通过将属性设置为来取消该事件 Cancel true 。You can validate the data, or you can cancel the event by setting the Cancel property to true. 通过在属性中更改对象的值,可以修改要删除的记录 OriginalObject 。You can modify which record is deleted by changing the value or values of the object in the OriginalObject property.