DetailsViewMode 열거형

정의

DetailsView 컨트롤의 각기 다른 데이터 입력 모드를 나타냅니다.

public enum class DetailsViewMode
public enum DetailsViewMode
type DetailsViewMode = 
Public Enum DetailsViewMode
상속
DetailsViewMode

필드

Edit 1

사용자가 기존 레코드의 값을 업데이트하는 데 사용할 수 있는 편집 모드입니다.

Insert 2

사용자가 새 레코드의 값을 입력하는 데 사용할 수 있는 삽입 모드입니다.

ReadOnly 0

사용자가 레코드의 값을 수정하지 못하도록 방지하는 디스플레이 모드입니다.

예제

다음 코드 예제에서는 유지 하는 방법에 설명 합니다 DetailsView 컨트롤을 편집 모드로 설정 하 여 업데이트 작업 후 합니다 DefaultMode 속성을 DetailsViewMode.Edit.


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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>DetailsView DefaultMode Example</title>
</head>
<body>
    <form id="Form1" runat="server">
        
      <h3>DetailsView DefaultMode Example</h3>
                
        <asp:detailsview id="CustomerDetailView"
          datasourceid="DetailsViewSource"
          datakeynames="CustomerID"
          autogenerateeditbutton="true"   
          autogeneraterows="true"
          allowpaging="true"
          defaultmode="Edit"   
          runat="server">
               
          <headerstyle backcolor="Navy"
            forecolor="White"/>
                    
        </asp:detailsview>
        
        <!-- 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" runat="server" 
          ConnectionString=
            "<%$ ConnectionStrings:NorthWindConnectionString%>"
          InsertCommand="INSERT INTO [Customers]([CustomerID],
            [CompanyName], [Address], [City], [PostalCode], [Country]) 
            VALUES (@CustomerID, @CompanyName, @Address, @City, 
            @PostalCode, @Country)"

          SelectCommand="Select [CustomerID], [CompanyName], 
            [Address], [City], [PostalCode], [Country] From 
            [Customers]">
        </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">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>DetailsView DefaultMode Example</title>
</head>
<body>
    <form id="Form1" runat="server">
        
      <h3>DetailsView DefaultMode Example</h3>
                
        <asp:detailsview id="CustomerDetailView"
          datasourceid="DetailsViewSource"
          datakeynames="CustomerID"
          autogenerateeditbutton="true"   
          autogeneraterows="true"
          allowpaging="true"
          defaultmode="Edit"   
          runat="server">
               
          <headerstyle backcolor="Navy"
            forecolor="White"/>
                    
        </asp:detailsview>
        
        <!-- 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" runat="server" 
          ConnectionString=
            "<%$ ConnectionStrings:NorthWindConnectionString%>"
          InsertCommand="INSERT INTO [Customers]([CustomerID],
            [CompanyName], [Address], [City], [PostalCode], [Country]) 
            VALUES (@CustomerID, @CompanyName, @Address, @City, 
            @PostalCode, @Country)"

          SelectCommand="Select [CustomerID], [CompanyName], 
            [Address], [City], [PostalCode], [Country] From 
            [Customers]">
        </asp:SqlDataSource>
    </form>
  </body>
</html>

설명

DetailsViewMode 열거형의 데이터 입력 모드를 나타내는 데는 DetailsView 제어 합니다. 컨트롤의 현재 모드를 확인 하려면 사용 된 CurrentMode 속성입니다. 삽입 또는 업데이트 작업 후는 DetailsView 제어가 반환 하 여 지정 된 모드는 DefaultMode 속성입니다. 기본적으로 컨트롤 읽기 전용 모드로 돌아갑니다. 로 설정 하 여 돌아갑니다 대체 모드를 지정할 수 있습니다는 DefaultMode 속성입니다. 모드를 프로그래밍 방식으로 변경 하려면 사용 된 ChangeMode 메서드. 경우는 DetailsView 컨트롤 모드를 변경, 다음 표에 이벤트가 발생 합니다.

이벤트 설명
ModeChanging 발생 경우를 DetailsView 컨트롤 모드를 실제로 변경 되기 전에 하지만 편집, 삽입 및 읽기 전용 모드 사이 변경 하 려 합니다. 이 이벤트는 종종 모드 변경을 취소 하려면 사용 합니다.
ModeChanged 이후에 발생 한 DetailsView 컨트롤 편집, 삽입 또는 읽기 전용 모드에서 다른 모드로 변경 되었습니다. 작업을 수행 하려면이 이벤트는 대개 때는 DetailsView 컨트롤 모드를 변경 합니다.

적용 대상

추가 정보