LinqDataSourceStatusEventArgs.ExceptionHandled 속성

정의

예외가 처리되었으며 다시 throw되어서는 안 되는지 여부를 나타내는 값을 가져오거나 설정합니다.

public:
 property bool ExceptionHandled { bool get(); void set(bool value); };
public bool ExceptionHandled { get; set; }
member this.ExceptionHandled : bool with get, set
Public Property ExceptionHandled As Boolean

속성 값

예외가 처리되었으면 true이고, 그렇지 않으면 false입니다.

예제

다음 예제에서는 이벤트 처리기는 Inserted 이벤트입니다. 이벤트 처리기에서 경우는 Exception 속성은 null, 제품 ID의 개체에서 검색 되는 Result 속성입니다. 제품 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

설명

에 대 한 이벤트 처리기를 만들 수 있습니다 합니다 ContextCreated, DeletedInserted, Selected, 및 Updated 이러한 작업 중에 발생 하는 모든 예외를 검사 하는 이벤트입니다. 예외를 처리 하 고 다시 throw 되도록 원하지 않는 경우 설정 합니다 ExceptionHandled 속성을 true입니다. 설정 하지 않으면 경우는 ExceptionHandled 속성을 true, 예외 호출 스택에 있는 다음 이벤트 처리기에 전파 됩니다.

적용 대상