FormView.FooterTemplate プロパティ
アセンブリ: System.Web (system.web.dll 内)
構文
<TemplateContainerAttribute(GetType(FormView))> _ Public Overridable Property FooterTemplate As ITemplate
Dim instance As FormView Dim value As ITemplate value = instance.FooterTemplate instance.FooterTemplate = value
[TemplateContainerAttribute(typeof(FormView))] public virtual ITemplate FooterTemplate { get; set; }
[TemplateContainerAttribute(typeof(FormView))] public: virtual property ITemplate^ FooterTemplate { ITemplate^ get (); void set (ITemplate^ value); }
/** @property */ public ITemplate get_FooterTemplate () /** @property */ public void set_FooterTemplate (ITemplate value)
public function get FooterTemplate () : ITemplate public function set FooterTemplate (value : ITemplate)
フッター行のカスタム コンテンツを含んだ System.Web.UI.ITemplate。既定値は null 参照 (Visual Basic では Nothing) で、このプロパティが設定されていないことを示します。
FooterText プロパティまたは FooterTemplate プロパティが設定されている場合、FormView コントロールの下部にフッター行が表示されます。FooterTemplate プロパティを使用して、フッター行に独自のカスタム ユーザー インターフェイス (UI) を定義できます。フッター行のカスタム テンプレートを指定するには、最初に <FooterTemplate> タグを FormView コントロールの開始タグと終了タグの間に配置します。その後、<FooterTemplate> の開始タグと終了タグの間に、テンプレートの内容のリストを記述できます。フッター行のスタイルを制御するには、FooterStyle プロパティを使用します。また、このプロパティの代わりに FooterText プロパティを設定して、単にフッター行にテキストを表示することもできます。
メモ |
---|
FooterText プロパティと FooterTemplate プロパティの両方が設定されている場合は、FooterTemplate プロパティが優先されます。 |
FooterTemplate プロパティを使用して、フッター行に表示するカスタム テンプレートを定義する方法を次の例に示します。
<%@ Page language="VB" %> <script runat="server"> Sub EmployeeFormView_ItemCreated(ByVal sender As Object, ByVal e As EventArgs) ' Use the FooterRow property to retrieve the footer row. Dim footer As FormViewRow = EmployeeFormView.FooterRow ' Retrieve the FooterLabel Label control from the footer row. Dim footerLabel As Label = CType(footer.FindControl("FooterLabel"), Label) If footerLabel IsNot Nothing Then ' Display the current page number. Dim currentPage As Integer = EmployeeFormView.PageIndex + 1 footerLabel.Text = "Page " & currentPage.ToString() End If End Sub </script> <html> <body> <form runat="server"> <h3>FormView FooterTemplate Example</h3> <asp:formview id="EmployeeFormView" datasourceid="EmployeeSource" allowpaging="true" datakeynames="EmployeeID" onitemcreated="EmployeeFormView_ItemCreated" runat="server"> <footertemplate> <table> <tr> <td> <asp:image id="LogoImage" imageurl="~/Images/LogoImage.jpg" runat="server"/> </td> <td> <asp:label id="FooterLabel" runat="server"/> </td> </tr> </table> </footertemplate> <footerstyle horizontalalign="Center" forecolor="White" backcolor="LightBlue"/> <itemtemplate> <table> <tr> <td> <asp:image id="EmployeeImage" imageurl='<%# Eval("PhotoPath") %>' alternatetext='<%# Eval("LastName") %>' runat="server"/> </td> <td> <h3><%# Eval("FirstName") %> <%# Eval("LastName") %></h3> <%# Eval("Title") %> </td> </tr> </table> </itemtemplate> <pagersettings position="Bottom" mode="NextPrevious"/> </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]" connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" runat="server"/> </form> </body> </html>
<%@ Page language="C#" %> <script runat="server"> void EmployeeFormView_ItemCreated(Object sender, EventArgs e) { // Use the FooterRow property to retrieve the footer row. FormViewRow footer = EmployeeFormView.FooterRow; // Retrieve the FooterLabel Label control from the footer row. Label footerLabel = (Label)footer.FindControl("FooterLabel"); if(footerLabel != null) { // Display the current page number. int currentPage = EmployeeFormView.PageIndex + 1; footerLabel.Text = "Page " + currentPage.ToString(); } } </script> <html> <body> <form runat="server"> <h3>FormView FooterTemplate Example</h3> <asp:formview id="EmployeeFormView" datasourceid="EmployeeSource" allowpaging="true" datakeynames="EmployeeID" onitemcreated="EmployeeFormView_ItemCreated" runat="server"> <footertemplate> <table> <tr> <td> <asp:image id="LogoImage" imageurl="~/Images/LogoImage.jpg" runat="server"/> </td> <td> <asp:label id="FooterLabel" runat="server"/> </td> </tr> </table> </footertemplate> <footerstyle horizontalalign="Center" forecolor="White" backcolor="LightBlue"/> <itemtemplate> <table> <tr> <td> <asp:image id="EmployeeImage" imageurl='<%# Eval("PhotoPath") %>' alternatetext='<%# Eval("LastName") %>' runat="server"/> </td> <td> <h3><%# Eval("FirstName") %> <%# Eval("LastName") %></h3> <%# Eval("Title") %> </td> </tr> </table> </itemtemplate> <pagersettings position="Bottom" mode="NextPrevious"/> </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]" 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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
- FormView.FooterTemplate プロパティのページへのリンク