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设置为 ,则异常将传播到调用堆栈中的下一个事件处理程序。

适用于