GridViewDeleteEventArgs GridViewDeleteEventArgs GridViewDeleteEventArgs GridViewDeleteEventArgs Class

정의

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

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

예제

다음 예제에서는 사용 하는 방법의 GridViewDeleteEventArgs 이벤트 처리기에 전달 되는 개체입니다.The following example shows how to use the GridViewDeleteEventArgs object that is passed to the event handler. 코드에서 마지막 레코드를 제거 하려면 사용자가 삭제 작업을 취소 한 GridView 제어 합니다.The code cancels the delete operation if the user tries to remove the last record from a GridView control.


<%@ 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 CustomersGridView_RowDeleting
        (Object sender, GridViewDeleteEventArgs e)
    {
        TableCell cell = CustomersGridView.Rows[e.RowIndex].Cells[2];
        if (cell.Text == "Beaver")
        {
            e.Cancel = true;
            Message.Text = "You cannot delete customer Beaver.";
        }
        else
        {
            Message.Text = "";
        }
    }  

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>GridView RowDeleting Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <h3>
        GridView RowDeleting Example
    </h3>
    <asp:Label ID="Message" ForeColor="Red" runat="server" />
    <br />
    <asp:GridView ID="CustomersGridView" runat="server" 
        DataSourceID="CustomersSqlDataSource" 
        AutoGenerateColumns="False"
        AutoGenerateDeleteButton="True" 
        OnRowDeleting="CustomersGridView_RowDeleting"
        DataKeyNames="CustomerID,AddressID">
        <Columns>
            <asp:BoundField DataField="FirstName" 
                HeaderText="FirstName" SortExpression="FirstName" />
            <asp:BoundField DataField="LastName" HeaderText="LastName" 
                SortExpression="LastName" />
            <asp:BoundField DataField="City" HeaderText="City" 
                SortExpression="City" />
            <asp:BoundField DataField="StateProvince" HeaderText="State" 
                SortExpression="StateProvince" />
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="CustomersSqlDataSource" runat="server"
        SelectCommand="SELECT SalesLT.CustomerAddress.CustomerID, 
            SalesLT.CustomerAddress.AddressID, 
            SalesLT.Customer.FirstName, 
            SalesLT.Customer.LastName, 
            SalesLT.Address.City, 
            SalesLT.Address.StateProvince 
            FROM SalesLT.Customer 
            INNER JOIN SalesLT.CustomerAddress 
            ON SalesLT.Customer.CustomerID = 
                SalesLT.CustomerAddress.CustomerID 
            INNER JOIN SalesLT.Address ON SalesLT.CustomerAddress.AddressID = 
                SalesLT.Address.AddressID"
        DeleteCommand="Delete from SalesLT.CustomerAddress where CustomerID = 
            @CustomerID and AddressID = @AddressID" 
        ConnectionString="<%$ ConnectionStrings:AdventureWorksLTConnectionString %>">
        <DeleteParameters>
            <asp:Parameter Name="AddressID" />
            <asp:Parameter Name="CustomerID" />
        </DeleteParameters>
    </asp:SqlDataSource>
    </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">

    Private Sub CustomersGridView_RowDeleting _
        (ByVal sender As [Object], _
        ByVal e As GridViewDeleteEventArgs)
        Dim cell As TableCell
        cell = CustomersGridView.Rows(e.RowIndex).Cells(2)
        If cell.Text = "Beaver" Then
            e.Cancel = True
            Message.Text = "You cannot delete customer Beaver."
        Else
            Message.Text = ""
        End If
    End Sub
    
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>GridView RowDeleting Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <h3>
        GridView RowDeleting Example
    </h3>
    <asp:Label ID="Message" ForeColor="Red" runat="server" />
    <br />
    <asp:GridView ID="CustomersGridView" runat="server" 
        DataSourceID="CustomersSqlDataSource" 
        AutoGenerateColumns="False"
        AutoGenerateDeleteButton="True" 
        OnRowDeleting="CustomersGridView_RowDeleting"
        DataKeyNames="CustomerID,AddressID">
        <Columns>
            <asp:BoundField DataField="FirstName" 
                HeaderText="FirstName" SortExpression="FirstName" />
            <asp:BoundField DataField="LastName" HeaderText="LastName" 
                SortExpression="LastName" />
            <asp:BoundField DataField="City" HeaderText="City" 
                SortExpression="City" />
            <asp:BoundField DataField="StateProvince" HeaderText="State" 
                SortExpression="StateProvince" />
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="CustomersSqlDataSource" runat="server"
        SelectCommand="SELECT SalesLT.CustomerAddress.CustomerID, 
            SalesLT.CustomerAddress.AddressID, 
            SalesLT.Customer.FirstName, 
            SalesLT.Customer.LastName, 
            SalesLT.Address.City, 
            SalesLT.Address.StateProvince 
            FROM SalesLT.Customer 
            INNER JOIN SalesLT.CustomerAddress 
            ON SalesLT.Customer.CustomerID = 
                SalesLT.CustomerAddress.CustomerID 
            INNER JOIN SalesLT.Address ON SalesLT.CustomerAddress.AddressID = 
                SalesLT.Address.AddressID"
        DeleteCommand="Delete from SalesLT.CustomerAddress where CustomerID = 
            @CustomerID and AddressID = @AddressID" 
        ConnectionString="<%$ ConnectionStrings:AdventureWorksLTConnectionString %>">
        <DeleteParameters>
            <asp:Parameter Name="AddressID" />
            <asp:Parameter Name="CustomerID" />
        </DeleteParameters>
    </asp:SqlDataSource>
    </form>
</body>
</html>

설명

GridView 를 발생 시킵니다 합니다 RowDeleting 삭제 단추를 클릭할 때 이벤트를 하기 전에 GridView 레코드를 삭제 합니다.The GridView control raises the RowDeleting event when a Delete button is clicked, but before the GridView control deletes the record. 삭제 단추는 해당 CommandName 속성이 "Delete"로 설정되어 있는 단추 컨트롤입니다. 삭제 작업을 취소 하는 등이 이벤트가 발생할 때마다 사용자 지정 루틴을 수행할 수 있습니다.(A Delete button is a button control whose CommandName property is set to "Delete".) You can perform a custom routine whenever this event occurs, such as canceling the delete operation.

GridViewDeleteEventArgs 개체가 이벤트 처리기에 전달 됩니다.A GridViewDeleteEventArgs object is passed to the event handler. 이렇게 하면 삭제할 행의 인덱스를 확인 하 고 삭제 작업을 취소할 수 있습니다.This enables you to determine the index of the row being deleted and to cancel the delete operation. 삭제 작업을 취소 하려면 합니다 Cancel 의 속성을 GridViewDeleteEventArgs 개체를 true입니다.To cancel the delete operation, set the Cancel property of the GridViewDeleteEventArgs object to true. 조작할 수도 있습니다는 KeysValues 값이 데이터 원본에 전달 되기 전에 컬렉션입니다.You can also manipulate the Keys and Values collections before the values are passed to the data source.

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

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

생성자

GridViewDeleteEventArgs(Int32) GridViewDeleteEventArgs(Int32) GridViewDeleteEventArgs(Int32) GridViewDeleteEventArgs(Int32)

GridViewDeleteEventArgs 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the GridViewDeleteEventArgs 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 a dictionary of field name/value pairs that represent the primary key of the row to delete.

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 row 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)

적용 대상

추가 정보