ListViewCancelEventArgs.CancelMode Property

 

Gets the data-entry mode that the ListView control was in when the Cancel button was clicked.

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

public ListViewCancelMode CancelMode { get; }

Use the CancelMode property to determine whether the ListView control was in edit or insert mode when the Cancel button was clicked.

The following example shows how to use the CancelMode property to determine the data-entry mode that the ListView control was in when the user clicked the Cancel button. This code example is part of a larger example provided for the ListViewCancelEventArgs class.

protected void ContactsListView_ItemCanceling(object sender, ListViewCancelEventArgs e)
{
  //Check the operation that raised the event
  if (e.CancelMode == ListViewCancelMode.CancelingEdit)
  {
    // The update operation was canceled. Display the 
    // primary key of the item.
    Message.Text = "Update for the ContactID " + 
      ContactsListView.DataKeys[e.ItemIndex].Value.ToString()  + " canceled.";
  }
  else
  {
    Message.Text = "Insert operation canceled."; 
  }
}

.NET Framework
Available since 3.5
Return to top
Show: