LinqDataSourceInsertEventArgs.ExceptionHandled Propriedade

Definição

Recebe ou define um valor que indica se a exceção foi tratada e que não deve ser lançada novamente.

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

Valor de Propriedade

true se a exceção foi tratada; caso contrário, false.

Exemplos

O exemplo seguinte mostra um gestor de eventos para o Inserting evento. Apresenta quaisquer mensagens de exceção de validação usando um Label controlo.

Protected Sub LinqDataSource_Inserting(ByVal sender As Object, _
        ByVal e As LinqDataSourceInsertEventArgs)
    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_Inserting(object sender,
        LinqDataSourceInsertEventArgs 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;
    }
}

Observações

Pode criar gestores de eventos para o Inserting evento, para examinar exceções de validação que ocorreram antes da operação de inserção. Se tratar da exceção e não quiser que ela volte a ser lançada, defina a ExceptionHandled propriedade para true. Se não definir a ExceptionHandled propriedade para true, a exceção será propagada para o próximo gestor de eventos na pilha de chamadas.

Aplica-se a