DetailsView.FooterTemplate Proprietà

Definizione

Ottiene o imposta il contenuto definito dall'utente per la riga del piè di pagina in un controllo DetailsView.

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.DetailsView))]
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.DetailsView))>]
member this.FooterTemplate : System.Web.UI.ITemplate with get, set
Public Overridable Property FooterTemplate As ITemplate

Valore della proprietà

ITemplate

Oggetto ITemplate con il contenuto personalizzato per la riga del piè di pagina. Il valore predefinito è null, a indicare che questa proprietà non è impostata.

Attributi

Esempio

Nell'esempio di codice seguente viene illustrato come usare la FooterTemplate proprietà per creare una riga del piè di pagina personalizzata.


<%@ 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">

    protected void CustomerDetailView_DataBound(object sender, 
        EventArgs e)
    {
        // Get the footer row.
        DetailsViewRow footerRow = CustomerDetailView.FooterRow;

        // Get the Label control that displays the current page 
        // information from the footer row.
        Label pageNum = 
            (Label)footerRow.Cells[0].FindControl("PageNumberLabel");

        if (pageNum != null)
        {

            // Update the Label control with the current page number.
            int page = CustomerDetailView.DataItemIndex + 1;
            pageNum.Text = "Page " + page.ToString();

        }
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>DetailsView FooterTemplate Example</title>
</head>
<body>
    <form id="Form1" runat="server">
        
      <h3>DetailsView FooterTemplate Example</h3>
                
        <asp:detailsview id="CustomerDetailView"
          datasourceid="DetailsViewSource"
          datakeynames="CustomerID"
          autogeneraterows="true"
          allowpaging="true"
          runat="server" 
          OnDataBound="CustomerDetailView_DataBound">
               
          <headerstyle backcolor="Navy"
            forecolor="White"/>
            
          <pagersettings Mode="NextPreviousFirstLast"/>  
            
          <FooterTemplate>
          
            <table width="100%">            
              <tr>
                <td align="left">
                  <asp:Image id="LogoImage"
                    AlternateText="Our logo" 
                    imageurl="~\images\Logo.jpg"
                    runat="server"/>
                </td>
                <td align="right" valign="bottom">
                  <asp:Label id="PageNumberLabel"
                    font-size="9"
                    forecolor="DodgerBlue"
                    runat="server"/>
                </td>
              </tr>            
            </table>
          
          </FooterTemplate>
                    
        </asp:detailsview>
        
        <!-- 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="DetailsViewSource" runat="server" 
          ConnectionString=
            "<%$ ConnectionStrings:NorthWindConnectionString%>"
          InsertCommand="INSERT INTO [Customers]([CustomerID],
            [CompanyName], [Address], [City], [PostalCode], [Country]) 
            VALUES (@CustomerID, @CompanyName, @Address, @City, 
            @PostalCode, @Country)"

          SelectCommand="Select [CustomerID], [CompanyName], 
            [Address], [City], [PostalCode], [Country] From 
            [Customers]">
        </asp:SqlDataSource>
    </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">

    Protected Sub CustomerDetailView_DataBound(ByVal sender As Object, _
        ByVal e As EventArgs)
        ' Get the footer row.
        Dim footerRow As DetailsViewRow = CustomerDetailView.FooterRow

        ' Get the Label control that displays the current page 
        ' information from the footer row.
        Dim pageNum As Label = _
            CType(footerRow.Cells(0).FindControl("PageNumberLabel"), Label)

        If pageNum IsNot Nothing Then
            ' Update the Label control with the current page number.
            Dim page As Integer = CustomerDetailView.DataItemIndex + 1
            pageNum.Text = "Page " + page.ToString()
        End If
    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>DetailsView FooterTemplate Example</title>
</head>
<body>
    <form id="Form1" runat="server">
        
      <h3>DetailsView FooterTemplate Example</h3>
                
        <asp:detailsview id="CustomerDetailView"
          datasourceid="DetailsViewSource"
          datakeynames="CustomerID"
          autogeneraterows="true"
          allowpaging="true"
          runat="server" 
          OnDataBound="CustomerDetailView_DataBound">
               
          <headerstyle backcolor="Navy"
            forecolor="White"/>
            
          <pagersettings Mode="NextPreviousFirstLast"/>  
            
          <FooterTemplate>
          
            <table width="100%">            
              <tr>
                <td align="left">
                  <asp:Image id="LogoImage"
                    AlternateText="Our logo" 
                    imageurl="~\images\Logo.jpg"
                    runat="server"/>
                </td>
                <td align="right" valign="bottom">
                  <asp:Label id="PageNumberLabel"
                    font-size="9"
                    forecolor="DodgerBlue"
                    runat="server"/>
                </td>
              </tr>            
            </table>
          
          </FooterTemplate>
                    
        </asp:detailsview>
        
        <!-- 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="DetailsViewSource" runat="server" 
          ConnectionString=
            "<%$ ConnectionStrings:NorthWindConnectionString%>"
          InsertCommand="INSERT INTO [Customers]([CustomerID],
            [CompanyName], [Address], [City], [PostalCode], [Country]) 
            VALUES (@CustomerID, @CompanyName, @Address, @City, 
            @PostalCode, @Country)"

          SelectCommand="Select [CustomerID], [CompanyName], 
            [Address], [City], [PostalCode], [Country] From 
            [Customers]">
        </asp:SqlDataSource>
    </form>
  </body>
</html>

Commenti

La riga piè di pagina viene visualizzata nella parte inferiore del DetailsView controllo quando la FooterText proprietà o FooterTemplate è impostata. È possibile definire la propria interfaccia utente personalizzata per la riga piè di pagina usando la FooterTemplate proprietà . Per specificare un modello personalizzato per la riga piè di pagina, posizionare <FooterTemplate> i tag tra i tag di apertura e chiusura del DetailsView controllo. È quindi possibile elencare il contenuto del modello tra i tag di apertura e chiusura <FooterTemplate> . Per controllare lo stile della riga del piè di pagina, usare la FooterStyle proprietà . In alternativa, è possibile visualizzare semplicemente il testo nella riga piè di pagina impostando la FooterText proprietà anziché questa proprietà.

Nota

Se entrambe le FooterText proprietà e FooterTemplate sono impostate, la proprietà ha la FooterTemplate precedenza.

Si applica a

Vedi anche