Redigera

Dela via


ListViewCancelEventArgs.CancelMode Property

Definition

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

public:
 property System::Web::UI::WebControls::ListViewCancelMode CancelMode { System::Web::UI::WebControls::ListViewCancelMode get(); };
public System.Web.UI.WebControls.ListViewCancelMode CancelMode { get; }
member this.CancelMode : System.Web.UI.WebControls.ListViewCancelMode
Public ReadOnly Property CancelMode As ListViewCancelMode

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.

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."; 
  }
}
Protected Sub ContactsListView_ItemCanceling(ByVal sender As Object, _
                                             ByVal e As ListViewCancelEventArgs)
  'Check the operation that raised the event
  If (e.CancelMode = ListViewCancelMode.CancelingEdit) Then
    ' 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."
  End If

End Sub

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

See also