FormView.DefaultMode プロパティ
メモ : このプロパティは、.NET Framework version 2.0 で新しく追加されたものです。
FormView コントロールが更新、挿入、またはキャンセルの各操作後に戻る、データ入力モードを取得または設定します。
名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)
構文
Dim instance As FormView Dim value As FormViewMode value = instance.DefaultMode instance.DefaultMode = value
public: virtual property FormViewMode DefaultMode { FormViewMode get (); void set (FormViewMode value); }
/** @property */ public FormViewMode get_DefaultMode () /** @property */ public void set_DefaultMode (FormViewMode value)


DefaultMode プロパティを使用して、FormView コントロールが更新、挿入、または削除の各操作の実行後に、編集、挿入、または読み取り専用のいずれのモードに戻るのかを指定します。既定では、FormView コントロールは読み取り専用モードに戻りますが、このプロパティを適切な値に設定することによって、FormView コントロールを編集モードまたは挿入モードのまま維持できます。さまざまなモード値の一覧を次の表に示します。
FormViewMode.Edit | |
FormViewMode.Insert | FormView コントロールは挿入モードになっています。この場合、ユーザーは、データ ソースに新しいレコードを追加できます。 |
FormViewMode.ReadOnly |
このプロパティは通常、FormView コントロールの目的が 1 つだけ (レコードの挿入、編集など) の場合に使用されます。

DefaultMode プロパティを使用して、更新操作後に FormView コントロールを編集モードのまま維持する方法を次の例に示します。
<%@ Page language="VB" %> <html> <body> <form 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="C#" %> <html> <body> <form 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>

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.DefaultMode プロパティを検索する場合は、下記のリンクをクリックしてください。

- FormView.DefaultMode プロパティのページへのリンク