ListViewCancelEventArgs.CancelMode Property

Definition

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

C#
public System.Web.UI.WebControls.ListViewCancelMode CancelMode { get; }

Property Value

One of the ListViewCancelMode values.

Examples

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.

C#
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."; 
  }
}

Remarks

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

Applies to

Product Versions
.NET Framework 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also