FormView.ChangeMode メソッド
アセンブリ: System.Web (system.web.dll 内)

Public Sub ChangeMode ( _ newMode As FormViewMode _ )
public void ChangeMode ( FormViewMode newMode )
public: void ChangeMode ( FormViewMode newMode )
public void ChangeMode ( FormViewMode newMode )
public function ChangeMode ( newMode : FormViewMode )

ChangeMode メソッドを使用して、プログラムによって FormView コントロールを編集、挿入、および読み取り専用の各モード間で切り替えます。また、このメソッドは、指定したモードで CurrentMode プロパティを更新します。さまざまなモード値の一覧を次の表に示します。

ChangeMode メソッドを使用して、ユーザーが別のレコードに移動するたびに FormView コントロールを読み取り専用モードに戻す方法を次の例に示します。
<%@ Page language="VB" %> <script runat="server"> Sub EmployeeFormView_PageIndexChanged(ByVal sender As Object, ByVal e As EventArgs) ' By default, if the FormView control is in edit mode and ' the user navigates to another page, the FormView control ' remains in edit mode. In this example, the ChangeMode ' method is used to return the FormView control to read-only ' mode whenever the user navigates to another record. EmployeeFormView.ChangeMode(FormViewMode.ReadOnly) End Sub </script> <html> <body> <form runat="server"> <h3>FormView ChangeMode Example</h3> <asp:formview id="EmployeeFormView" datasourceid="EmployeeSource" allowpaging="true" datakeynames="EmployeeID" emptydatatext="No employees found." onpageindexchanged="EmployeeFormView_PageIndexChanged" 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"/> <asp:linkbutton id="CancelButton" text="Cancel" commandname="Cancel" 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="C#" %> <script runat="server"> void EmployeeFormView_PageIndexChanged(Object sender, EventArgs e) { // By default, if the FormView control is in edit mode and // the user navigates to another page, the FormView control // remains in edit mode. In this example, the ChangeMode // method is used to return the FormView control to read-only // mode whenever the user navigates to another record. EmployeeFormView.ChangeMode(FormViewMode.ReadOnly); } </script> <html> <body> <form runat="server"> <h3>FormView ChangeMode Example</h3> <asp:formview id="EmployeeFormView" datasourceid="EmployeeSource" allowpaging="true" datakeynames="EmployeeID" emptydatatext="No employees found." onpageindexchanged="EmployeeFormView_PageIndexChanged" 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"/> <asp:linkbutton id="CancelButton" text="Cancel" commandname="Cancel" 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>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からFormView.ChangeMode メソッドを検索する場合は、下記のリンクをクリックしてください。

- FormView.ChangeMode メソッドのページへのリンク