FormView.DefaultMode 속성
정의
public:
virtual property System::Web::UI::WebControls::FormViewMode DefaultMode { System::Web::UI::WebControls::FormViewMode get(); void set(System::Web::UI::WebControls::FormViewMode value); };
public virtual System.Web.UI.WebControls.FormViewMode DefaultMode { get; set; }
member this.DefaultMode : System.Web.UI.WebControls.FormViewMode with get, set
Public Overridable Property DefaultMode As FormViewMode
속성 값
FormViewMode 값 중 하나입니다.One of the FormViewMode values. 기본값은 FormViewMode.ReadOnly
입니다.The default is FormViewMode.ReadOnly
.
예외
지정한 값이 FormViewMode 열거형 값이 아닌 경우The specified value is not one of the FormViewMode enumeration values.
예제
다음 예제에서는 속성을 사용 하 여 DefaultMode FormView 업데이트 작업 후 컨트롤을 편집 모드로 유지 하는 방법을 보여 줍니다.The following example demonstrates how to use the DefaultMode property to keep a FormView control in edit mode after an update operation.
<%@ 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>FormView DefaultMode Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>FormView DefaultMode Example</h3>
<asp:formview id="EmployeeFormView"
datasourceid="EmployeeSource"
allowpaging="true"
datakeynames="EmployeeID"
defaultmode="Edit"
emptydatatext="No employees found."
runat="server">
<rowstyle backcolor="LightGreen"
wrap="false"/>
<editrowstyle backcolor="LightBlue"
wrap="false"/>
<itemtemplate>
<table>
<tr>
<td rowspan="4">
<asp:image id="EmployeeImage"
imageurl='<%# Eval("PhotoPath") %>'
alternatetext='<%# Eval("LastName") %>'
runat="server"/>
</td>
<td colspan="2">
</td>
</tr>
<tr>
<td>
<b>Name:</b>
</td>
<td>
<%# Eval("FirstName") %> <%# Eval("LastName") %>
</td>
</tr>
<tr>
<td>
<b>Title:</b>
</td>
<td>
<%# Eval("Title") %>
</td>
</tr>
<tr>
<td colspan="2">
<asp:linkbutton id="Edit"
text="Edit"
commandname="Edit"
runat="server"/>
</td>
</tr>
</table>
</itemtemplate>
<edititemtemplate>
<table>
<tr>
<td rowspan="4">
<asp:image id="EmployeeEditImage"
imageurl='<%# Eval("PhotoPath") %>'
alternatetext='<%# Eval("LastName") %>'
runat="server"/>
</td>
<td colspan="2">
</td>
</tr>
<tr>
<td>
<b>Name:</b>
</td>
<td>
<asp:textbox id="FirstNameUpdateTextBox"
text='<%# Bind("FirstName") %>'
runat="server"/>
<asp:textbox id="LastNameUpdateTextBox"
text='<%# Bind("LastName") %>'
runat="server"/>
</td>
</tr>
<tr>
<td>
<b>Title:</b>
</td>
<td>
<asp:textbox id="TitleUpdateTextBox"
text='<%# Bind("Title") %>'
runat="server"/>
</td>
</tr>
<tr>
<td colspan="2">
<asp:linkbutton id="UpdateButton"
text="Update"
commandname="Update"
runat="server"/>
</td>
</tr>
</table>
</edititemtemplate>
</asp:formview>
<!-- 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]"
updatecommand="Update [Employees] Set [LastName]=@LastName, [FirstName]=@FirstName, [Title]=@Title 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">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>FormView DefaultMode Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>FormView DefaultMode Example</h3>
<asp:formview id="EmployeeFormView"
datasourceid="EmployeeSource"
allowpaging="true"
datakeynames="EmployeeID"
defaultmode="Edit"
emptydatatext="No employees found."
runat="server">
<rowstyle backcolor="LightGreen"
wrap="false"/>
<editrowstyle backcolor="LightBlue"
wrap="false"/>
<itemtemplate>
<table>
<tr>
<td rowspan="4">
<asp:image id="EmployeeImage"
imageurl='<%# Eval("PhotoPath") %>'
alternatetext='<%# Eval("LastName") %>'
runat="server"/>
</td>
<td colspan="2">
</td>
</tr>
<tr>
<td>
<b>Name:</b>
</td>
<td>
<%# Eval("FirstName") %> <%# Eval("LastName") %>
</td>
</tr>
<tr>
<td>
<b>Title:</b>
</td>
<td>
<%# Eval("Title") %>
</td>
</tr>
<tr>
<td colspan="2">
<asp:linkbutton id="Edit"
text="Edit"
commandname="Edit"
runat="server"/>
</td>
</tr>
</table>
</itemtemplate>
<edititemtemplate>
<table>
<tr>
<td rowspan="4">
<asp:image id="EmployeeEditImage"
imageurl='<%# Eval("PhotoPath") %>'
alternatetext='<%# Eval("LastName") %>'
runat="server"/>
</td>
<td colspan="2">
</td>
</tr>
<tr>
<td>
<b>Name:</b>
</td>
<td>
<asp:textbox id="FirstNameUpdateTextBox"
text='<%# Bind("FirstName") %>'
runat="server"/>
<asp:textbox id="LastNameUpdateTextBox"
text='<%# Bind("LastName") %>'
runat="server"/>
</td>
</tr>
<tr>
<td>
<b>Title:</b>
</td>
<td>
<asp:textbox id="TitleUpdateTextBox"
text='<%# Bind("Title") %>'
runat="server"/>
</td>
</tr>
<tr>
<td colspan="2">
<asp:linkbutton id="UpdateButton"
text="Update"
commandname="Update"
runat="server"/>
</td>
</tr>
</table>
</edititemtemplate>
</asp:formview>
<!-- 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]"
updatecommand="Update [Employees] Set [LastName]=@LastName, [FirstName]=@FirstName, [Title]=@Title Where [EmployeeID]=@EmployeeID"
connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
runat="server"/>
</form>
</body>
</html>
설명
속성을 사용 DefaultMode 하 여 FormView 업데이트, 삽입 또는 취소 작업이 수행 된 후 컨트롤이 편집, 삽입 또는 읽기 전용 모드로 반환 되는지 여부를 지정 합니다.Use the DefaultMode property to specify whether the FormView control returns to edit, insert, or read-only mode after an update, insert, or cancel operation is performed. 기본적으로 컨트롤은 FormView 읽기 전용 모드로 돌아갑니다. 그러나 FormView 이 속성을 적절 한 값으로 설정 하 여 컨트롤을 편집 또는 삽입 모드로 유지할 수 있습니다.By default, the FormView control returns to read-only mode; however, you can keep the FormView control in edit or insert mode by setting this property to the appropriate value. 다음 표에서는 다양 한 모드 값을 나열 합니다.The following table lists the different mode values.
ModeMode | DescriptionDescription |
---|---|
FormViewMode.Edit |
FormView컨트롤이 편집 모드에 있으므로 사용자가 레코드의 값을 업데이트할 수 있습니다.The FormView control is in edit mode, which allows the user to update the values of a record. |
FormViewMode.Insert |
FormView컨트롤이 삽입 모드에 있으므로 사용자가 데이터 소스에 새 레코드를 추가할 수 있습니다.The FormView control is in insert mode, which allows the user to add a new record to the data source. |
FormViewMode.ReadOnly |
FormView컨트롤이 표준 디스플레이 모드인 읽기 전용 모드입니다.The FormView control is in read-only mode, which is the normal display mode. |
이 속성은 FormView 레코드를 삽입 하거나 편집 하는 것과 같은 단일 용도가 컨트롤에 있는 경우에 일반적으로 사용 됩니다.This property is commonly used when the FormView control has a single purpose, such as only to insert or edit records.