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 值之一。

示例

以下示例演示如何使用 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插入模式。

适用于

另请参阅