共用方式為


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控制件在按下 [取消] 按鈕時處於編輯或插入模式。

適用於

另請參閱