LinqDataSourceStatusEventArgs 类     
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
为 ContextCreated、Deleted、Inserted、Selected 和 Updated 事件提供数据。
public ref class LinqDataSourceStatusEventArgs : EventArgs
	public class LinqDataSourceStatusEventArgs : EventArgs
	type LinqDataSourceStatusEventArgs = class
    inherit EventArgs
	Public Class LinqDataSourceStatusEventArgs
Inherits EventArgs
		- 继承
 
示例
以下示例显示了 事件的事件处理程序 Inserted 。 在事件处理程序中 Exception ,如果 属性为 null,则从 属性中的 Result 对象检索产品 ID。 产品 ID 是表的主键,由数据库设置,因此在插入操作完成之前,该值是未知的。 如果 Exception 属性不等于 null,则会记录异常消息。 然后, 属性 ExceptionHandled 设置为 true。
protected void LinqDataSource_Inserted(object sender, LinqDataSourceStatusEventArgs e)
{
    if (e.Exception == null)
    {
        Product newProduct = (Product)e.Result;
        Literal1.Text = "The new product id is " + newProduct.ProductID;
        Literal1.Visible = true;            
    }
    else
    {
        LogError(e.Exception.Message);
        Literal1.Text = "We are sorry. There was a problem saving the record. The administrator has been notified.";
        Literal1.Visible = true;
        e.ExceptionHandled = true;            
    }
}
Protected Sub LinqDataSource_Inserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LinqDataSourceStatusEventArgs)
    If (IsNothing(e.Exception)) Then
        Dim newProduct As Product
        newProduct = CType(e.Result, Product)
        Literal1.Text = "The new product id is " & newProduct.ProductID
        Literal1.Visible = True
    Else
        LogError(e.Exception.Message)
        Literal1.Text = "We are sorry. There was a problem saving the record. The administrator has been notified."
        Literal1.Visible = True
        e.ExceptionHandled = True
    End If
End Sub
	注解
使用 LinqDataSourceStatusEventArgs 类可以检查控件已执行 LinqDataSource 的数据操作的结果。 对象LinqDataSourceStatusEventArgs传递给控件的 ContextCreated、、DeletedInserted、 Selected和 Updated 事件的LinqDataSource事件处理程序。
如果数据操作成功完成,则生成的数据对象将存储在 属性中 Result , Exception 并且 属性为 null。 如果数据操作失败,则数据操作期间发生的异常存储在 属性中 Exception , Result 属性为 null。 如果处理了 属性表示的 Exception 异常,请将 属性 ExceptionHandled 设置为 true ,以便不会引发异常。
通过 TotalRowCount 属性检索从查询返回的数据记录总数。
构造函数
| LinqDataSourceStatusEventArgs(Exception) | 
		 使用数据操作所引发的异常初始化 LinqDataSourceStatusEventArgs 类的新实例。  | 
        	
| LinqDataSourceStatusEventArgs(Object) | 
		 使用包含数据操作结果数据的对象初始化 LinqDataSourceStatusEventArgs 类的新实例。  | 
        	
| LinqDataSourceStatusEventArgs(Object, Int32) | 
		 使用包含数据操作结果数据以及返回的行数的对象初始化 LinqDataSourceStatusEventArgs 类的新实例。  | 
        	
属性
| Exception | 
		 获取在数据操作过程中引发的异常。  | 
        	
| ExceptionHandled | 
		 获取或设置一个值,该值指示异常是否已得到处理而不该再次引发。  | 
        	
| Result | 
		 获取表示数据操作结果的对象。  | 
        	
| TotalRowCount | 
		 获取数据检索操作过程中在某个数据集中检索的总行数。  | 
        	
方法
| Equals(Object) | 
		 确定指定对象是否等于当前对象。 (继承自 Object) | 
        	
| GetHashCode() | 
		 作为默认哈希函数。 (继承自 Object) | 
        	
| GetType() | 
		 获取当前实例的 Type。 (继承自 Object) | 
        	
| MemberwiseClone() | 
		 创建当前 Object 的浅表副本。 (继承自 Object) | 
        	
| ToString() | 
		 返回表示当前对象的字符串。 (继承自 Object) |