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

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

FormView コントロールは、コントロールの (CurrentMode プロパティで指定された) 現在のモードに基づいて、異なるテンプレートをデータ行に表示します。各モードで使用されるテンプレートを次の表に示します。
ItemTemplate プロパティを使用して、FormView コントロールが読み取り専用モードの場合のデータ行に独自のユーザー インターフェイス (UI) を定義します。通常、項目テンプレートには、レコードのフィールド値を表示するためのコントロールと、レコードの編集、挿入、および削除を行うためのコマンド ボタンが含まれます。
カスタム テンプレートを指定するには、最初に、FormView コントロールの開始タグと終了タグの間に <ItemTemplate> タグを配置します。その後、<ItemTemplate> の開始タグと終了タグの間に、テンプレートの内容のリストを記述できます。コントロールにバインドされているデータ ソースのフィールド値を表示するには、データ バインド式を使用します。データ バインド式の詳細については、「データ バインド式構文」を参照してください。組み込みの削除、編集、および新規レコードの挿入の各操作を実行するコマンド ボタンを作成するには、CommandName プロパティを次の表の値のいずれかに設定して、コマンド ボタン コントロールをテンプレートに追加します。

読み取り専用モードのデータ行用のカスタム テンプレートを定義する方法を次の例に示します。
<%@ Page language="VB" %> <html> <body> <form runat="server"> <h3>FormView Example</h3> <asp:formview id="EmployeeFormView" datasourceid="EmployeeSource" allowpaging="true" datakeynames="EmployeeID" 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"/> <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#" %> <html> <body> <form runat="server"> <h3>FormView Example</h3> <asp:formview id="EmployeeFormView" datasourceid="EmployeeSource" allowpaging="true" datakeynames="EmployeeID" 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"/> <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.ItemTemplate プロパティを検索する場合は、下記のリンクをクリックしてください。

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