ListViewEditEventArgs.NewEditIndex Property

 

Gets the index of the item that is being edited.

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

Public ReadOnly Property NewEditIndex As Integer

Property Value

Type: System.Int32

The index of the item that is being edited.

Use the NewEditIndex property to determine the index of the item that is being edited. The item index is often used to retrieve this item from the Items collection of the ListView control, which enables you to access the item's properties.

The following example shows how to use the NewEditIndex property to retrieve the ListViewItem object that is being edited. This code example is part of a larger example provided for the ListViewEditEventArgs class.

Sub ProductsListView_ItemEditing(ByVal sender As Object, ByVal e As ListViewEditEventArgs)
  Dim item As ListViewItem = ProductsListView.Items(e.NewEditIndex)
  Dim dateLabel As Label = CType(item.FindControl("DiscontinuedDateLabel"), Label)

  If String.IsNullOrEmpty(dateLabel.Text) Then _
    Return

  'Verify if the item is discontinued.
  Dim discontinuedDate As DateTime = DateTime.Parse(dateLabel.Text)
  If discontinuedDate < DateTime.Now Then
    Message.Text = "You cannot edit a discontinued item."
    e.Cancel = True
    ProductsListView.SelectedIndex = -1
  End If
End Sub

.NET Framework
Available since 3.5
Return to top
Show: