FormViewDeleteEventArgs.Values FormViewDeleteEventArgs.Values FormViewDeleteEventArgs.Values FormViewDeleteEventArgs.Values Property

정의

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

public:
 property System::Collections::Specialized::IOrderedDictionary ^ Values { System::Collections::Specialized::IOrderedDictionary ^ get(); };
public System.Collections.Specialized.IOrderedDictionary Values { get; }
member this.Values : System.Collections.Specialized.IOrderedDictionary
Public ReadOnly Property Values As IOrderedDictionary

속성 값

삭제할 항목에 대한 키가 아닌 필드의 이름/값 쌍이 들어 있는 OrderedDictionary입니다.An OrderedDictionary that contains the non-key field name/value pairs for the item to delete.

예제

다음 예제에서는 사용 하는 방법에 설명 합니다 Values 속성을 삭제 하 고 레코드의 키가 아닌 필드의 값에 액세스 합니다.The following example demonstrates how to use the Values property to access the values of the non-key fields of the record being deleted.


<%@ 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>

설명

사용 된 Values 삭제할 레코드에 대 한 키가 아닌 필드의 값에 액세스 하는 속성입니다.Use the Values property to access the values of the non-key fields for the record to be deleted. 예를 들어, 레코드를 삭제 하기 전에 확인 또는 삭제 된 레코드의 로그를 유지할 이러한 값을 사용할 수 있습니다.For example, you can use these values to verify the record before deleting it, or to keep a log of deleted records.

참고

이 속성에는 키 필드는 없습니다.This property does not contain the key field or fields. 키 필드 또는 필드 이름/값 쌍 값에 액세스 하려면 사용 된 Keys 속성입니다.To access the name/value pair values for the key field or fields, use the Keys property.

Values 속성이 반환을 OrderedDictionary 구현 하는 개체는 System.Collections.Specialized.IOrderedDictionary 인터페이스.The Values property returns an OrderedDictionary object that implements the System.Collections.Specialized.IOrderedDictionary interface. 합니다 OrderedDictionary 개체에 들어 System.Collections.DictionaryEntry 키가 아닌 필드를 나타내는 개체입니다.The OrderedDictionary object contains System.Collections.DictionaryEntry objects that represent the non-key fields. 필드 이름에 액세스 하려면 사용 합니다 Keys 의 속성을 OrderedDictionary 개체.To access the field names, use the Keys property of the OrderedDictionary object. 마찬가지로, 필드 값을 사용 하 여 액세스할 수 있습니다는 Values 속성입니다.Similarly, you can access the field values by using the Values property.

참고

인덱스를 이용할 수 있습니다 가기로 OrderedDictionary 필드 값에 액세스 하는 개체입니다.As a shortcut, you can also use the indexer of the OrderedDictionary object to access the field values. 인덱서를 사용 하 여 장점은 필드 값이 직접 반환 된다는 것입니다.The advantage in using the indexer is that it returns field values directly. 데이터 소스 필드 순서에 의존 하는 컨트롤 (같은 AccessDataSource) 필드 값을 인덱스로 액세스할 수 있습니다.Data source controls that rely on the field order (such as AccessDataSource) can access field values only by index.

값을 Values 컬렉션 데이터 소스 컨트롤에 전달 되지 않습니다.The values in the Values collection do not get passed to the data source control. 데이터 원본 이러한 값 중 하나에 필요한 경우 이러한 값을 추가 해야 합니다 Keys 컬렉션입니다.If the data source requires any of these values, you should add these values to the Keys collection.

합니다 Keys 하 고 Values 속성은 읽기 전용;의 필드 값을 수정할 수 있습니다는 OrderedDictionary 개체입니다.The Keys and Values properties are read-only; however, you can modify the field values of the OrderedDictionary object. 키 및 키가 아닌 필드 값을 변경한 경우 해당 레코드를 데이터 소스에서 삭제 됩니다.If you change the key and non-key field values, the corresponding record will be deleted from the data source.

적용 대상

추가 정보