DetailsViewModeEventArgs 클래스

정의

ModeChanging 이벤트에 대한 데이터를 제공합니다.

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

예제

다음 코드 예제에 사용 하는 방법을 보여 줍니다.는 DetailsViewModeEventArgs 개체에 대 한 이벤트 처리기에 전달 합니다 ModeChanging 경우 이벤트를 숨기려면 페이저 행는 DetailsView 컨트롤이 편집 모드로 전환 합니다.


<%@ 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_ModeChanging(Object sender, DetailsViewModeEventArgs e)
  {

    // Use the NewMode property to determine the mode to which the 
    // DetailsView control is transitioning.
    switch (e.NewMode)
    {
      case DetailsViewMode.Edit:
        // Hide the pager row and clear the Label control
        // when transitioning to edit mode.
        CustomerDetailsView.AllowPaging = false;
        MessageLabel.Text = "";
        break;
      case DetailsViewMode.ReadOnly:
        // Display the pager row and confirmation message
        // when transitioning to edit mode.
        CustomerDetailsView.AllowPaging = true;
        if (e.CancelingEdit)
        {
          MessageLabel.Text = "Update canceled.";
        }
        else
        {
          MessageLabel.Text = "Update completed.";
        }
        break;
      case DetailsViewMode.Insert:
        // Cancel the mode change if the DetailsView
        // control attempts to transition to insert 
        // mode.
        e.Cancel = true;
        break;
      default:
        MessageLabel.Text = "Unsupported mode.";
        break;
    }
    
  }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>DetailsViewModeEventArgs Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>DetailsViewModeEventArgs Example</h3>
                
      <asp:detailsview id="CustomerDetailsView"
        datasourceid="DetailsViewSource"
        datakeynames="CustomerID"
        autogeneraterows="true"
        autogenerateeditbutton="true" 
        allowpaging="true"
        onmodechanging="CustomerDetailsView_ModeChanging" 
        runat="server">

      </asp:detailsview>
      
      <br/><br/>
      
      <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]"
        updatecommand="Update [Customers] Set 
          [CompanyName]=@CompanyName, [Address]=@Address, 
          [City]=@City, [PostalCode]=@PostalCode, 
          [Country]=@Country 
          Where [CustomerID]=@CustomerID" 
        connectionstring=
          "<%$ ConnectionStrings:NorthWindConnectionString%>" 
        runat="server"/>
            
    </form>
  </body>
</html>

<%@ Page language="VB" autoeventwireup="false" %>

<!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_ModeChanging(ByVal sender As Object, ByVal e As DetailsViewModeEventArgs) Handles CustomerDetailsView.ModeChanging

    ' Use the NewMode property to determine the mode to which the 
    ' DetailsView control is transitioning.
    Select Case e.NewMode
    
      Case DetailsViewMode.Edit
        ' Hide the pager row and clear the Label control
        ' when transitioning to edit mode.
        CustomerDetailsView.AllowPaging = False
        MessageLabel.Text = ""

      Case DetailsViewMode.ReadOnly
        ' Display the pager row and confirmation message
        ' when transitioning to edit mode.
        CustomerDetailsView.AllowPaging = True
        If e.CancelingEdit Then
        
          MessageLabel.Text = "Update canceled."
        
        Else
        
          MessageLabel.Text = "Update completed."
        
        End If

      Case DetailsViewMode.Insert
        ' Cancel the mode change if the DetailsView
        ' control attempts to transition to insert 
        ' mode.
        e.Cancel = True

      Case Else
        MessageLabel.Text = "Unsupported mode."
          
    End Select
    
  End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>DetailsViewModeEventArgs Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>DetailsViewModeEventArgs Example</h3>
                
      <asp:detailsview id="CustomerDetailsView"
        datasourceid="DetailsViewSource"
        datakeynames="CustomerID"
        autogeneraterows="true"
        autogenerateeditbutton="true" 
        allowpaging="true"
        runat="server">

      </asp:detailsview>
      
      <br/><br/>
      
      <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]"
        updatecommand="Update [Customers] Set 
          [CompanyName]=@CompanyName, [Address]=@Address, 
          [City]=@City, [PostalCode]=@PostalCode, 
          [Country]=@Country 
          Where [CustomerID]=@CustomerID" 
        connectionstring=
          "<%$ ConnectionStrings:NorthWindConnectionString%>" 
        runat="server"/>
            
    </form>
  </body>
</html>

설명

ModeChanging 이벤트가 발생할 때를 DetailsView 컨트롤 모드를 실제로 변경 되기 전에 하지만 편집, 삽입 및 읽기 전용 모드 사이 변경 하 려 합니다. 구성 하는 등 사용자 지정 루틴을 수행 하는 이벤트 처리기를 제공할 수 있습니다는 DetailsView 특정 모드에 대 한 제어 하거나이 이벤트가 발생할 때마다 모드 변경 내용을 취소 합니다.

A DetailsViewModeEventArgs 모드를 결정할 수 있게 하는 이벤트 처리기에 전달 된 개체는를 DetailsView 결정할 컨트롤이 변경 되 여부를 ModeChanging 사용자 편집 작업 취소로 인해 또는 나타내는 이벤트가 발생 삽입 작업을 취소 해야 한다는 합니다. 새 모드를 확인 하려면 사용 된 NewMode 속성입니다. 사용할 수도 있습니다는 NewMode 중 하나로 설정 하 여 대체 모드를 변경 하려면 속성을 DetailsViewMode 열거형 값입니다. 사용 된 CancelingEdit 사용자가 편집 작업을 취소 여부를 결정 하는 속성입니다. 삽입 작업을 취소 하려면 합니다 Cancel 속성을 true입니다.

이벤트를 처리 하는 방법에 대 한 자세한 내용은 참조 하세요. 이벤트 처리 및 발생합니다.

DetailsViewModeEventArgs 클래스의 인스턴스에 대한 초기 속성 값 목록은 DetailsViewModeEventArgs 생성자를 참조하십시오.

생성자

DetailsViewModeEventArgs(DetailsViewMode, Boolean)

DetailsViewModeEventArgs 클래스의 새 인스턴스를 초기화합니다.

속성

Cancel

이벤트를 취소해야 할지 여부를 나타내는 값을 가져오거나 설정합니다.

(다음에서 상속됨 CancelEventArgs)
CancelingEdit

ModeChanging 이벤트가 사용자의 편집 작업 취소로 인해 발생했는지 여부를 나타내는 값을 가져옵니다.

NewMode

DetailsView 컨트롤이 전환될 모드를 가져오거나 설정합니다.

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상

추가 정보