ListViewUpdatedEventArgs.AffectedRows Propriedade

Definição

Obtém o número de linhas afetadas pela operação de atualização.Gets the number of rows that were affected by the update operation.

public:
 property int AffectedRows { int get(); };
public int AffectedRows { get; }
member this.AffectedRows : int
Public ReadOnly Property AffectedRows As Integer

Valor da propriedade

Int32

O número de linhas afetadas pela operação de atualização.The number of rows that were affected by the update operation.

Exemplos

O exemplo a seguir mostra como usar a AffectedRows propriedade para verificar se um item foi atualizado.The following example shows how to use the AffectedRows property to verify that an item was updated. Este exemplo de código faz parte de um exemplo maior fornecido para a ListViewUpdatedEventArgs classe.This code example is part of a larger example provided for the ListViewUpdatedEventArgs class.

void ContactsListView_ItemUpdated(Object sender, ListViewUpdatedEventArgs e)
{
    if (e.Exception != null)
    {
        if (e.AffectedRows == 0)
        {
            e.KeepInEditMode = true;
            Message.Text = "An exception occurred updating the contact. " +
                                "Please verify your values and try again.";
        }
        else
            Message.Text = "An exception occurred updating the contact. " +
                                "Please verify the values in the recently updated item.";

        e.ExceptionHandled = true;
    }
}
Sub ContactsListView_ItemUpdated(sender As Object, e As ListViewUpdatedEventArgs)
    If e.Exception IsNot Nothing Then
        If e.AffectedRows = 0 Then
            e.KeepInEditMode = True
            Message.Text = "An exception occurred updating the contact. " & _
                                "Please verify your values and try again."
        Else
            Message.Text = "An exception occurred updating the contact. " & _
                                "Please verify the values in the recently updated item."
        End If

        e.ExceptionHandled = True
    End If
End Sub

Comentários

Use a AffectedRows propriedade para determinar o número de linhas que foram afetadas pela operação de atualização, conforme retornado pela fonte de dados.Use the AffectedRows property to determine the number of rows that were affected by the update operation, as returned by the data source. Como normalmente apenas um item é atualizado, essa propriedade geralmente contém um valor de 0 ou 1.Because typically only one item is updated, this property usually contains a value of 0 or 1.

Às vezes, durante a operação de atualização, pode ocorrer um erro que não gera uma exceção.Sometimes during the update operation an error can occur that does not raise an exception. Nesse caso, a AffectedRows propriedade pode ser usada para verificar se um item foi atualizado.In that case, the AffectedRows property can be used to verify that an item was updated.

Aplica-se a

Confira também