DetailsView.DefaultMode 속성

정의

DetailsView 컨트롤의 기본 데이터 입력 모드를 가져오거나 설정합니다.

public:
 virtual property System::Web::UI::WebControls::DetailsViewMode DefaultMode { System::Web::UI::WebControls::DetailsViewMode get(); void set(System::Web::UI::WebControls::DetailsViewMode value); };
public virtual System.Web.UI.WebControls.DetailsViewMode DefaultMode { get; set; }
member this.DefaultMode : System.Web.UI.WebControls.DetailsViewMode with get, set
Public Overridable Property DefaultMode As DetailsViewMode

속성 값

DetailsViewMode

DetailsViewMode 값 중 하나입니다. 기본값은 DetailsViewMode.ReadOnly입니다.

예외

지정한 값이 DetailsViewMode 열거형 값이 아닌 경우

예제

다음 코드 예제에서는 레코드가 업데이트 된 후 컨트롤 편집 모드로 유지 되도록 지정 하는 DetailsView 속성을 사용 DefaultMode 하는 방법을 보여 줍니다.


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

설명

DefaultMode 편집 또는 삽입 작업을 수행한 후 컨트롤이 DetailsView 편집, 삽입 또는 읽기 전용 모드로 반환되는지 여부를 지정하려면 이 속성을 사용합니다. 기본적으로 컨트롤은 DetailsView 읽기 전용 모드로 돌아갑니다. 그러나 이 속성을 적절한 값으로 설정하여 컨트롤을 DetailsView 편집 또는 삽입 모드로 유지할 수 있습니다. 다음 표에는 다양한 모드 값이 나와 있습니다.

Mode Description
DetailsViewMode.Edit 컨트롤이 DetailsView 편집 모드에 있으므로 사용자가 레코드 값을 업데이트할 수 있습니다.
DetailsViewMode.Insert 컨트롤이 DetailsView 삽입 모드에 있으므로 사용자가 데이터 원본에 새 레코드를 추가할 수 있습니다.
DetailsViewMode.ReadOnly DetailsView 컨트롤은 일반 디스플레이 모드인 읽기 전용 모드입니다.

적용 대상

추가 정보