FormViewDeleteEventArgs FormViewDeleteEventArgs FormViewDeleteEventArgs FormViewDeleteEventArgs Class

정의

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

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

예제

다음 예제에서는 사용 하는 방법에 설명 합니다 FormViewDeleteEventArgs 개체에 대 한 이벤트 처리 메서드에 전달는 ItemDeleting 삭제 작업을 취소 하는 이벤트입니다.The following example demonstrates how to use the FormViewDeleteEventArgs object passed to the event-handling method 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 EmployeeFormView_ItemDeleting(Object sender, FormViewDeleteEventArgs e)
  {
    // Get the employee ID, name, and job title from the Keys and Values
    // properties.
    String keyValue = e.Keys["EmployeeID"].ToString();
    String employeeName = e.Values["FirstName"].ToString() +
      " " + e.Values["LastName"].ToString();
    String title = e.Values["Title"].ToString();

    // Cancel the delete operation if the user attempts to 
    // delete a protected record. In this example, records for
    // employees with a "Sales Manager" job title are protected.
    if (title.Equals("Sales Manager"))
    {
      e.Cancel = true;
      MessageLabel.Text = "You cannot delete record " +
        e.RowIndex.ToString() + ". " + employeeName +
        " (Employee Number " + keyValue.ToString() +
        ") is protected.";
    }

  }
   
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>FormViewDeleteEventArgs Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>FormViewDeleteEventArgs Example</h3>
                       
      <asp:formview id="EmployeeFormView"
        datasourceid="EmployeeSource"
        allowpaging="true"
        datakeynames="EmployeeID"
        onitemdeleting="EmployeeFormView_ItemDeleting"  
        runat="server">
        
        <itemtemplate>
        
          <table>
            <tr>
              <td>
                <asp:image id="EmployeeImage"
                  imageurl='<%# Eval("PhotoPath") %>'
                  alternatetext='<%# Eval("LastName") %>' 
                  runat="server"/>
              </td>
              <td>
                <asp:label id="FirstNameLabel"
                  text='<%#Bind("FirstName")%>'
                  font-bold="true"
                  runat="server"/>
                <asp:label id="LastNameLabel"
                  text='<%#Bind("LastName")%>'
                  font-bold="true"
                  runat="server"/>
                <br/>     
                <asp:label id="TitleLabel"
                  text='<%#Bind("Title")%>'
                  runat="server"/>        
              </td>
            </tr>
            <tr>
              <td colspan="2">
                <asp:button id="DeleteButton"
                  text="Delete Record"
                  commandname="Delete"
                  runat="server" />
              </td>
            </tr>
          </table>
        
        </itemtemplate>         
                  
      </asp:formview>
      
      <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="EmployeeSource"
        selectcommand="Select [EmployeeID], [LastName], [FirstName], [Title], [PhotoPath] From [Employees]"
        deletecommand="Delete [Employees] Where [EmployeeID]=@EmployeeID"
        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 EmployeeFormView_ItemDeleting(ByVal sender As Object, ByVal e As FormViewDeleteEventArgs)
  
    ' Get the employee ID, name, and job title from the Keys and Values
    ' properties.
    Dim keyValue As String = e.Keys("EmployeeID").ToString()
    Dim employeeName As String = e.Values("FirstName").ToString() & _
      " " & e.Values("LastName").ToString()
    Dim title As String = e.Values("Title").ToString()

    ' Cancel the delete operation if the user attempts to 
    ' delete a protected record. In this example, records for
    ' employees with a "Sales Manager" job title are protected.
    If Title.Equals("Sales Manager") Then
    
      e.Cancel = True
      MessageLabel.Text = "You cannot delete record " & _
        e.RowIndex.ToString() & ". " & employeeName & _
        " (Employee Number " & keyValue.ToString() & _
        ") is protected."
    
    End If

  End Sub
   
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>FormViewDeleteEventArgs Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>FormViewDeleteEventArgs Example</h3>
                       
      <asp:formview id="EmployeeFormView"
        datasourceid="EmployeeSource"
        allowpaging="true"
        datakeynames="EmployeeID"
        onitemdeleting="EmployeeFormView_ItemDeleting"  
        runat="server">
        
        <itemtemplate>
        
          <table>
            <tr>
              <td>
                <asp:image id="EmployeeImage"
                  imageurl='<%# Eval("PhotoPath") %>'
                  alternatetext='<%# Eval("LastName") %>' 
                  runat="server"/>
              </td>
              <td>
                <asp:label id="FirstNameLabel"
                  text='<%#Bind("FirstName")%>'
                  font-bold="true"
                  runat="server"/>
                <asp:label id="LastNameLabel"
                  text='<%#Bind("LastName")%>'
                  font-bold="true"
                  runat="server"/>
                <br/>     
                <asp:label id="TitleLabel"
                  text='<%#Bind("Title")%>'
                  runat="server"/>        
              </td>
            </tr>
            <tr>
              <td colspan="2">
                <asp:button id="DeleteButton"
                  text="Delete Record"
                  commandname="Delete"
                  runat="server" />
              </td>
            </tr>
          </table>
        
        </itemtemplate>         
                  
      </asp:formview>
      
      <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="EmployeeSource"
        selectcommand="Select [EmployeeID], [LastName], [FirstName], [Title], [PhotoPath] From [Employees]"
        deletecommand="Delete [Employees] Where [EmployeeID]=@EmployeeID"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" 
        runat="server"/>
            
    </form>
  </body>
</html>

설명

FormView 를 발생 시킵니다를 ItemDeleting 이벤트 있는 삭제 단추 (단추를 사용 하 여 해당 CommandName 속성이 "Delete"로 설정) 컨트롤 내에서 클릭 하기 전에 FormView 레코드를 삭제 합니다.The FormView 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 FormView control deletes the record. 이 옵션을 사용 하면 레코드를 삭제 하기 전에이 이벤트가 발생할 때마다 확인 하는 등 사용자 지정 루틴을 수행 하는 이벤트 처리 메서드를 제공할 수 있습니다.This allows you to provide an event-handling method that performs a custom routine, such as verifying a record before deleting it, whenever this event occurs.

FormViewDeleteEventArgs 개체는 삭제할 레코드의 인덱스를 확인 하 고 삭제 작업을 취소 해야 함을 나타낼 수는 이벤트 처리 메서드에 전달 됩니다.A FormViewDeleteEventArgs object is passed to the event-handling method, 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.

참고

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

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

FormViewDeleteEventArgs 클래스의 인스턴스에 대한 초기 속성 값 목록은 FormViewDeleteEventArgs 생성자를 참조하십시오.For a list of initial property values for an instance of the FormViewDeleteEventArgs class, see the FormViewDeleteEventArgs constructor.

생성자

FormViewDeleteEventArgs(Int32) FormViewDeleteEventArgs(Int32) FormViewDeleteEventArgs(Int32) FormViewDeleteEventArgs(Int32)

FormViewDeleteEventArgs 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the FormViewDeleteEventArgs 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 for the record to delete.

RowIndex RowIndex RowIndex RowIndex

데이터 소스에서 삭제하고 있는 레코드의 인덱스를 가져옵니다.Gets the index of the record being deleted from the data source.

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)

적용 대상

추가 정보