FormView.InsertItemTemplate プロパティ
アセンブリ: System.Web (system.web.dll 内)

<TemplateContainerAttribute(GetType(FormView), BindingDirection.TwoWay)> _ Public Overridable Property InsertItemTemplate As ITemplate
Dim instance As FormView Dim value As ITemplate value = instance.InsertItemTemplate instance.InsertItemTemplate = value
[TemplateContainerAttribute(typeof(FormView), BindingDirection.TwoWay)] public virtual ITemplate InsertItemTemplate { get; set; }
[TemplateContainerAttribute(typeof(FormView), BindingDirection::TwoWay)] public: virtual property ITemplate^ InsertItemTemplate { ITemplate^ get (); void set (ITemplate^ value); }
/** @property */ public ITemplate get_InsertItemTemplate () /** @property */ public void set_InsertItemTemplate (ITemplate value)
public function get InsertItemTemplate () : ITemplate public function set InsertItemTemplate (value : ITemplate)
FormView コントロールが挿入モードの場合のデータ行のカスタム コンテンツを含む System.Web.UI.ITemplate。既定値は null で、このプロパティが設定されていないことを示します。

FormView コントロールは、コントロールの (CurrentMode プロパティで指定された) 現在のモードに基づいて、異なるテンプレートをデータ行に表示します。各モードで使用されるテンプレートを次の表に示します。
InsertItemTemplate プロパティを使用して、FormView コントロールが挿入モードの場合のデータ行に独自のユーザー インターフェイス (UI) を定義します。通常、項目挿入テンプレートには、ユーザーが新規レコードの値を入力するための入力コントロールと、レコードを挿入したり、挿入操作をキャンセルしたりするためのコマンド ボタンが含まれます。
カスタム テンプレートを指定するには、最初に、FormView コントロールの開始タグと終了タグの間に <InsertItemTemplate> タグを配置します。その後、<InsertItemTemplate> の開始タグと終了タグの間に、テンプレートの内容のリストを記述できます。双方向のバインド式を使用すると、フィールドを入力コントロールに関連付けることができます。レコードが挿入されると、FormView コントロールは、自動的に、関連付けられた入力コントロールから更新されたフィールド値を抽出します。双方向のバインド式の詳細については、「データベースへのバインド」を参照してください。組み込みのキャンセル操作や挿入操作を実行するコマンド ボタンを作成するには、CommandName プロパティを次の表の値のいずれかに設定して、コマンド ボタン コントロールをテンプレートに追加します。

挿入モードのデータ行にカスタム テンプレートを定義する方法を次の例に示します。
<%@ Page language="VB" %> <html> <body> <form runat="server"> <h3>FormView InsertItemTemplate Example</h3> <asp:formview id="EmployeeFormView" datasourceid="EmployeeSource" allowpaging="true" datakeynames="EmployeeID" emptydatatext="No employees found." runat="server"> <rowstyle backcolor="LightGreen" wrap="false"/> <insertrowstyle backcolor="LightBlue" wrap="false"/> <itemtemplate> <table> <tr> <td rowspan="5"> <asp:image id="CompanyLogoImage" imageurl="~/Images/Logo.jpg" alternatetext="Company Logo" 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="NewButton" text="New" commandname="New" runat="server"/> </td> </tr> </table> </itemtemplate> <insertitemtemplate> <table> <tr> <td rowspan="4"> <asp:image id="CompanyLogoEditImage" imageurl="~/Images/Logo.jpg" alternatetext="Company Logo" runat="server"/> </td> <td colspan="2"> </td> </tr> <tr> <td> <b>Name:</b> </td> <td> <asp:textbox id="FirstNameInsertTextBox" text='<%# Bind("FirstName") %>' runat="server"/> <asp:textbox id="LastNameInsertTextBox" text='<%# Bind("LastName") %>' runat="server"/> </td> </tr> <tr> <td> <b>Title:</b> </td> <td> <asp:textbox id="TitleInsertTextBox" text='<%# Bind("Title") %>' runat="server"/> </td> </tr> <tr> <td colspan="2"> <asp:linkbutton id="InsertButton" text="Insert" commandname="Insert" runat="server"/> <asp:linkbutton id="CancelButton" text="Cancel" commandname="Cancel" runat="server"/> </td> </tr> </table> </insertitemtemplate> </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]" insertcommand="Insert Into [Employees] ([LastName], [FirstName], [Title]) VALUES (@LastName, @FirstName, @Title)" connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" runat="server"/> </form> </body> </html>
<%@ Page language="C#" %> <html> <body> <form runat="server"> <h3>FormView InsertItemTemplate Example</h3> <asp:formview id="EmployeeFormView" datasourceid="EmployeeSource" allowpaging="true" datakeynames="EmployeeID" emptydatatext="No employees found." runat="server"> <rowstyle backcolor="LightGreen" wrap="false"/> <insertrowstyle backcolor="LightBlue" wrap="false"/> <itemtemplate> <table> <tr> <td rowspan="5"> <asp:image id="CompanyLogoImage" imageurl="~/Images/Logo.jpg" alternatetext="Company Logo" 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="NewButton" text="New" commandname="New" runat="server"/> </td> </tr> </table> </itemtemplate> <insertitemtemplate> <table> <tr> <td rowspan="4"> <asp:image id="CompanyLogoEditImage" imageurl="~/Images/Logo.jpg" alternatetext="Company Logo" runat="server"/> </td> <td colspan="2"> </td> </tr> <tr> <td> <b>Name:</b> </td> <td> <asp:textbox id="FirstNameInsertTextBox" text='<%# Bind("FirstName") %>' runat="server"/> <asp:textbox id="LastNameInsertTextBox" text='<%# Bind("LastName") %>' runat="server"/> </td> </tr> <tr> <td> <b>Title:</b> </td> <td> <asp:textbox id="TitleInsertTextBox" text='<%# Bind("Title") %>' runat="server"/> </td> </tr> <tr> <td colspan="2"> <asp:linkbutton id="InsertButton" text="Insert" commandname="Insert" runat="server"/> <asp:linkbutton id="CancelButton" text="Cancel" commandname="Cancel" runat="server"/> </td> </tr> </table> </insertitemtemplate> </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]" insertcommand="Insert Into [Employees] ([LastName], [FirstName], [Title]) VALUES (@LastName, @FirstName, @Title)" 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.InsertItemTemplate プロパティを検索する場合は、下記のリンクをクリックしてください。

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