DetailsView.FooterRow Propriété

Définition

Obtient un objet DetailsViewRow qui représente la ligne de pied de page dans un contrôle DetailsView.

public:
 virtual property System::Web::UI::WebControls::DetailsViewRow ^ FooterRow { System::Web::UI::WebControls::DetailsViewRow ^ get(); };
[System.ComponentModel.Browsable(false)]
public virtual System.Web.UI.WebControls.DetailsViewRow FooterRow { get; }
[<System.ComponentModel.Browsable(false)>]
member this.FooterRow : System.Web.UI.WebControls.DetailsViewRow
Public Overridable ReadOnly Property FooterRow As DetailsViewRow

Valeur de propriété

DetailsViewRow qui représente la ligne de pied de page dans un contrôle DetailsView.

Attributs

Exemples

L’exemple de code suivant montre comment utiliser la FooterRow propriété pour accéder à la ligne de pied de page du DetailsView contrôle pendant l’événement ItemCreated . Un Label contrôle dans la ligne de pied de page personnalisée est ensuite mis à jour avec le numéro de page actuel.


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

Remarques

La ligne de pied de page s’affiche en bas du contrôle lorsque la DetailsViewFooterText propriété ou FooterTemplate est définie. Utilisez la FooterRow propriété pour accéder par programmation à l’objet DetailsViewRow qui représente la ligne de pied de page.

Notes

La FooterRow propriété n’est disponible qu’une fois que le DetailsView contrôle a créé la ligne de pied de page dans l’événement ItemCreated .

Cette propriété est couramment utilisée lorsque vous devez manipuler par programmation la ligne de pied de page, par exemple lors de l’ajout de contenu personnalisé. Toute modification de la FooterRow propriété doit être effectuée après le rendu du DetailsView contrôle ; sinon, le DetailsView contrôle remplacera les modifications.

Pour contrôler le style de la ligne de pied de page, utilisez la FooterStyle propriété .

S’applique à

Voir aussi