Share via


LinqDataSourceUpdateEventArgs.ExceptionHandled 屬性

定義

取得或設定值,這個值表示是否處理了例外狀況以及是否不應再度擲回此例外狀況。

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

範例

下列範例顯示 事件的事件處理常式 Updating 。 它會使用 Label 控制項顯示任何驗證例外狀況訊息。

Protected Sub LinqDataSource_Updating(ByVal sender As Object, _  
        ByVal e As LinqDataSourceUpdateEventArgs)  
    If (e.Exception IsNot Nothing) Then  
        For Each innerException As KeyValuePair(Of String, Exception) _  
               In e.Exception.InnerExceptions  
            Label1.Text &= innerException.Key & ": " & _  
                innerException.Value.Message & "<br />"  
        Next  
        e.ExceptionHandled = True  
    End If  
End Sub  
protected void LinqDataSource_Updating(object sender,   
        LinqDataSourceUpdateEventArgs e)  
{  
    if (e.Exception != null)  
    {  
        foreach (KeyValuePair<string, Exception> innerException in   
             e.Exception.InnerExceptions)  
        {  
        Label1.Text += innerException.Key + ": " +   
            innerException.Value.Message + "<br />";  
        }  
        e.ExceptionHandled = true;  
    }  
}  

備註

您可以建立 Updating 事件的事件處理常式,以檢查更新作業之前發生的驗證例外狀況。 如果您處理例外狀況,而不想再次擲回例外狀況,請將 ExceptionHandled 屬性設定為 true 。 如果您未將 ExceptionHandled 屬性設定為 true ,例外狀況將會傳播至呼叫堆疊中的下一個事件處理常式。

適用於