ListViewUpdatedEventArgs.AffectedRows Proprietà

Definizione

Ottiene il numero di righe interessate dall'operazione di aggiornamento.

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

Valore della proprietà

Int32

Numero di righe interessate dall'operazione di aggiornamento.

Esempio

Nell'esempio seguente viene illustrato come utilizzare la AffectedRows proprietà per verificare che un elemento sia stato aggiornato. Questo esempio di codice fa parte di un esempio più ampio fornito per la ListViewUpdatedEventArgs classe .

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

Commenti

Utilizzare la AffectedRows proprietà per determinare il numero di righe interessate dall'operazione di aggiornamento, come restituito dall'origine dati. Poiché in genere viene aggiornato un solo elemento, questa proprietà contiene in genere un valore pari a 0 o 1.

In alcuni casi durante l'operazione di aggiornamento può verificarsi un errore che non genera un'eccezione. In tal caso, la AffectedRows proprietà può essere utilizzata per verificare che un elemento sia stato aggiornato.

Si applica a

Vedi anche