FormView.FooterTemplate Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan atau mengatur konten yang ditentukan pengguna untuk baris footer dalam FormView kontrol.
public:
virtual property System::Web::UI::ITemplate ^ FooterTemplate { System::Web::UI::ITemplate ^ get(); void set(System::Web::UI::ITemplate ^ value); };
[System.ComponentModel.Browsable(false)]
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
[System.Web.UI.TemplateContainer(typeof(System.Web.UI.WebControls.FormView))]
public virtual System.Web.UI.ITemplate FooterTemplate { get; set; }
[<System.ComponentModel.Browsable(false)>]
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
[<System.Web.UI.TemplateContainer(typeof(System.Web.UI.WebControls.FormView))>]
member this.FooterTemplate : System.Web.UI.ITemplate with get, set
Public Overridable Property FooterTemplate As ITemplate
Nilai Properti
ITemplate yang berisi konten kustom untuk baris footer. Nilai defaultnya adalah null, yang menunjukkan bahwa properti ini tidak diatur.
- Atribut
Contoh
Contoh berikut menunjukkan cara menggunakan FooterTemplate properti untuk menentukan templat kustom yang akan dirender untuk baris footer.
<%@ Page language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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 xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>FormView FooterTemplate Example</title>
</head>
<body>
<form id="form1" 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"
alternatetext="Our Logo"
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="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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 xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>FormView FooterTemplate Example</title>
</head>
<body>
<form id="form1" 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"
alternatetext="Our Logo"
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>
Keterangan
Baris footer ditampilkan di bagian FormView bawah kontrol saat FooterText properti atau FooterTemplate diatur. Anda dapat menentukan antarmuka pengguna kustom (UI) Anda sendiri untuk baris footer dengan menggunakan FooterTemplate properti . Untuk menentukan templat kustom untuk baris footer, pertama-tama tempatkan <FooterTemplate> tag antara tag FormView pembuka dan penutup kontrol. Anda kemudian dapat mencantumkan konten templat antara tag pembuka dan penutup <FooterTemplate> . Untuk mengontrol gaya baris footer, gunakan FooterStyle properti . Atau, Anda cukup menampilkan teks di baris footer dengan mengatur FooterText properti alih-alih properti ini.
Nota
FooterText Jika properti dan FooterTemplate diatur, FooterTemplate properti diutamakan.