DetailsViewDeleteEventArgs DetailsViewDeleteEventArgs DetailsViewDeleteEventArgs DetailsViewDeleteEventArgs Class

정의

ItemDeleting 이벤트에 대한 데이터를 제공합니다.Provides data for the ItemDeleting event.

public ref class DetailsViewDeleteEventArgs : System::ComponentModel::CancelEventArgs
public class DetailsViewDeleteEventArgs : System.ComponentModel.CancelEventArgs
type DetailsViewDeleteEventArgs = class
    inherit CancelEventArgs
Public Class DetailsViewDeleteEventArgs
Inherits CancelEventArgs
상속
DetailsViewDeleteEventArgsDetailsViewDeleteEventArgsDetailsViewDeleteEventArgsDetailsViewDeleteEventArgs

예제

다음 코드 예제를 사용 하는 방법에 설명 합니다 DetailsViewDeleteEventArgs 에 대 한 이벤트 처리기에 전달 된 개체를 ItemDeleting 삭제 작업을 취소 하려면 이벤트.The following code example demonstrates how to use the DetailsViewDeleteEventArgs object passed to the event handler for the ItemDeleting event to cancel a delete operation.


<%@ Page language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

  void CustomerDetailsView_ItemDeleting(Object sender, 
    DetailsViewDeleteEventArgs e)
  {

    // Get customer ID and name from the Keys and Values
    // properties.
    String keyValue = e.Keys["CustomerID"].ToString();
    String customerName = e.Values["CompanyName"].ToString();

    // Cancel the delete operation if the user attempts to 
    // delete protected record. In this example, records
    // with a customer ID that starts with with "A" cannot
    // be deleted.
    if (keyValue.StartsWith("A"))
    {
      e.Cancel = true;
      MessageLabel.Text = "You cannot delete " +
        customerName + ". This customer is protected.";
    }
    else
    {
      MessageLabel.Text = "Row " + e.RowIndex.ToString() + 
        " deleted.";
    }

  }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>DetailsViewDeleteEventArgs Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>DetailsViewDeleteEventArgs Example</h3>
                
        <asp:detailsview id="CustomerDetailsView"
          datasourceid="DetailsViewSource"
          datakeynames="CustomerID"
          autogeneratedeletebutton="true"  
          autogeneraterows="true"
          allowpaging="true"
          onitemdeleting="CustomerDetailsView_ItemDeleting" 
          runat="server">
            
          <fieldheaderstyle backcolor="Navy"
            forecolor="White"/>
                    
        </asp:detailsview>
        
        <asp:label id="MessageLabel"
          forecolor="Red"
          runat="server"/>
            
        <!-- This example uses Microsoft SQL Server and connects  -->
        <!-- to the Northwind sample database. Use an ASP.NET     -->
        <!-- expression to retrieve the connection string value   -->
        <!-- from the web.config file.                            -->
        <asp:sqldatasource id="DetailsViewSource"
          selectcommand="Select [CustomerID], [CompanyName], [Address], 
            [City], [PostalCode], [Country] From [Customers]"
          deletecommand="Delete [Customers] 
            Where [CustomerID]=@CustomerID"
          connectionstring=
            "<%$ ConnectionStrings:NorthWindConnectionString%>" 
          runat="server"/>
            
      </form>
  </body>
</html>


<%@ Page language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

  Sub CustomerDetailsView_ItemDeleting(ByVal sender As Object, _
    ByVal e As DetailsViewDeleteEventArgs)

    ' Get customer ID and name from the Keys and Values
    ' properties.
    Dim keyValue As String = e.Keys("CustomerID").ToString()
    Dim customerName As String = e.Values("CompanyName").ToString()

    ' Cancel the delete operation if the user attempts to 
    ' delete protected record. In this example, records
    ' with a customer ID that starts with with "A" cannot
    ' be deleted.
    If keyValue.StartsWith("A") Then

      e.Cancel = True
      MessageLabel.Text = "You cannot delete " & _
        customerName & ". This customer is protected."
    
    Else
    
      MessageLabel.Text = "Row " & e.RowIndex.ToString() & _
        " deleted."
    
    End If
    
  End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>DetailsViewDeleteEventArgs Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>DetailsViewDeleteEventArgs Example</h3>
                
        <asp:detailsview id="CustomerDetailsView"
          datasourceid="DetailsViewSource"
          datakeynames="CustomerID"
          autogeneratedeletebutton="true"  
          autogeneraterows="true"
          allowpaging="true"
          onitemdeleting="CustomerDetailsView_ItemDeleting" 
          runat="server">
            
          <fieldheaderstyle backcolor="Navy"
            forecolor="White"/>
                    
        </asp:detailsview>
        
        <asp:label id="MessageLabel"
          forecolor="Red"
          runat="server"/>
            
        <!-- This example uses Microsoft SQL Server and connects  -->
        <!-- to the Northwind sample database. Use an ASP.NET     -->
        <!-- expression to retrieve the connection string value   -->
        <!-- from the web.config file.                            -->
        <asp:sqldatasource id="DetailsViewSource"
          selectcommand="Select [CustomerID], [CompanyName], [Address], 
            [City], [PostalCode], [Country] From [Customers]"
          deletecommand="Delete [Customers] 
            Where [CustomerID]=@CustomerID"
          connectionstring=
            "<%$ ConnectionStrings:NorthWindConnectionString%>" 
          runat="server"/>
            
      </form>
  </body>
</html>

설명

DetailsView 를 발생 시킵니다를 ItemDeleting 이벤트 있는 삭제 단추 (단추를 사용 하 여 해당 CommandName 속성이 "Delete"로 설정) 컨트롤 내에서 클릭 하기 전에 DetailsView 레코드를 삭제 합니다.The DetailsView control raises the ItemDeleting event when a Delete button (a button with its CommandName property set to "Delete") within the control is clicked, but before the DetailsView control deletes the record. 이 옵션을 사용 하면 레코드를 삭제 하기 전에이 이벤트가 발생할 때마다 확인 하는 등 사용자 지정 루틴을 수행 하는 이벤트 처리기를 제공할 수 있습니다.This allows you to provide an event handler that performs a custom routine, such as verifying a record before deleting it, whenever this event occurs.

DetailsViewDeletedEventArgs 개체는 삭제할 레코드의 인덱스를 확인 하 고 삭제 작업을 취소 해야 함을 나타낼 수는 이벤트 처리기에 전달 됩니다.A DetailsViewDeletedEventArgs object is passed to the event handler, which allows you to determine the index of the record being deleted and to indicate that the delete operation should be canceled. 레코드의 인덱스를 확인 하려면 사용 된 RowIndex 속성입니다.To determine the index of a record, use the RowIndex property. 삭제 작업을 취소 하려면 합니다 Cancel 속성을 true입니다.To cancel the delete operation, set the Cancel property to true. 사용 하 여 키와 키가 아닌 필드를 액세스할 수도 있습니다는 KeysValues 속성을 각각.You can also access the key fields and non-key fields by using the Keys and Values properties, respectively. 이러한 값은 레코드를 삭제 하기 전에 확인 하려는 경우에 유용 합니다.These values are useful if you want to verify the record before deleting it.

참고

키 필드 값을 수정 하는 것이 불가능 합니다 Keys 속성입니다.It is possible to modify the key field values in the Keys property. 이러한 값을 변경한 경우 새 키 필드 값에 해당 하는 레코드가 삭제 됩니다.If you change these values, the record that corresponds to the new key field values will be deleted.

이벤트를 처리 하는 방법에 대 한 자세한 내용은 참조 하세요. 이벤트 처리 및 발생합니다.For more information about how to handle events, see Handling and Raising Events.

인스턴스의 초기 속성 값의 목록을 DetailsViewDeleteEventArgs 클래스는 DetailsViewDeleteEventArgs 생성자입니다.For a list of initial property values for an instance of DetailsViewDeleteEventArgs class, see the DetailsViewDeleteEventArgs constructor.

생성자

DetailsViewDeleteEventArgs(Int32) DetailsViewDeleteEventArgs(Int32) DetailsViewDeleteEventArgs(Int32) DetailsViewDeleteEventArgs(Int32)

DetailsViewDeleteEventArgs 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the DetailsViewDeleteEventArgs class.

속성

Cancel Cancel Cancel Cancel

이벤트를 취소해야 할지 여부를 나타내는 값을 가져오거나 설정합니다.Gets or sets a value indicating whether the event should be canceled.

(Inherited from CancelEventArgs)
Keys Keys Keys Keys

삭제된 항목의 키 필드 값과 해당 이름이 들어 있는 키 필드 이름/값 쌍의 정렬된 사전을 가져옵니다.Gets an ordered dictionary of key field name/value pairs that contains the names and values of the key fields of the deleted items.

RowIndex RowIndex RowIndex RowIndex

삭제하고 있는 행의 인덱스를 가져옵니다.Gets the index of the row being deleted.

Values Values Values Values

삭제할 항목에 대한 키가 아닌 필드 이름/값 쌍의 사전을 가져옵니다.Gets a dictionary of the non-key field name/value pairs for the item to delete.

메서드

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

지정한 개체와 현재 개체가 같은지 여부를 확인합니다.Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

기본 해시 함수로 작동합니다.Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

현재 인스턴스의 Type을 가져옵니다.Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

현재 개체를 나타내는 문자열을 반환합니다.Returns a string that represents the current object.

(Inherited from Object)

적용 대상

추가 정보