Edit

Share via


ListViewUpdatedEventArgs.AffectedRows Property

Definition

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

Property Value

The number of rows that were affected by the update operation.

Examples

The following example shows how to use the AffectedRows property to verify that an item was updated. 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

Remarks

Use the AffectedRows property to determine the number of rows that were affected by the update operation, as returned by the data source. Because typically only one item is updated, this property usually contains a value of 0 or 1.

Sometimes during the update operation an error can occur that does not raise an exception. In that case, the AffectedRows property can be used to verify that an item was updated.

Applies to

See also