ListViewCancelEventArgs.CancelMode 属性

定义

获取单击“取消”按钮时 ListView 控件所处的数据输入模式。

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

属性值

ListViewCancelMode

ListViewCancelMode 值之一。

示例

以下示例演示如何使用 CancelMode 属性来确定用户单击“取消”按钮时控件处于的数据输入模式 ListView 。 此代码示例是为类提供的大型示例的 ListViewCancelEventArgs 一部分。

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

注解

使用 CancelMode 属性确定控件在单击“取消”按钮时处于 ListView 编辑或插入模式。

适用于

另请参阅