ListViewEditEventArgs.NewEditIndex Property
.NET Framework (current version)
Gets the index of the item that is being edited.
Assembly: System.Web.Extensions (in System.Web.Extensions.dll)
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.
void ProductsListView_ItemEditing(Object sender, ListViewEditEventArgs e) { ListViewItem item = ProductsListView.Items[e.NewEditIndex]; Label dateLabel = (Label)item.FindControl("DiscontinuedDateLabel"); if (String.IsNullOrEmpty(dateLabel.Text)) return; //Verify if the item is discontinued. DateTime discontinuedDate = DateTime.Parse(dateLabel.Text); if (discontinuedDate < DateTime.Now) { Message.Text = "You cannot edit a discontinued item."; e.Cancel = true; ProductsListView.SelectedIndex = -1; } }
.NET Framework
Available since 3.5
Available since 3.5
Show: