ListViewUpdatedEventArgs.AffectedRows Property

 

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

Namespace:   System.Web.UI.WebControls
Assembly:  System.Web.Extensions (in System.Web.Extensions.dll)

Public ReadOnly Property AffectedRows As Integer

Property Value

Type: System.Int32

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

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.

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.

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

.NET Framework
Available since 3.5
Return to top
Show: