NumericPagerField.ButtonCount Proprietà

Definizione

Ottiene o imposta il numero di pulsanti da visualizzare in un oggetto NumericPagerField.

public:
 property int ButtonCount { int get(); void set(int value); };
public int ButtonCount { get; set; }
member this.ButtonCount : int with get, set
Public Property ButtonCount As Integer

Valore della proprietà

Int32

Numero di pulsanti da visualizzare in un oggetto NumericPagerField. Il valore predefinito è 5.

Eccezioni

La proprietà ButtonCount è impostata su un valore minore di 1.

Esempio

Nell'esempio seguente viene illustrato come usare la ButtonCount proprietà per modificare il numero predefinito di pulsanti di pagina visualizzati nell'oggetto NumericPagerField di un DataPager controllo.

<%@ Page language="C#" %>
    
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head id="Head1" runat="server">
    <title>NumericPagerField Example</title>
    <style type="text/css">
      .PagerNormal
      {
        font: 9pt Verdana;
        color: #0066CF;
        border: solid 1px #778899;
        padding: 1px 4px;
        text-decoration:none;
      }
      .PagerCurrent
      {
        font: 9pt Verdana;
        border: solid 1px #778899;
        padding: 1px 4px;
        background-color: #FFD700;
      }
    </style>
  </head>
  <body>
    <form id="form1" runat="server">
        
      <h3>NumericPagerField Example</h3>
          
      <asp:ListView ID="ContactsListView" 
        DataSourceID="ContactsDataSource"
        runat="server">
        <LayoutTemplate>        
          <table cellpadding="2" width="640px" border="1" runat="server" id="tblContacts">
            <tr runat="server">
              <th runat="server">ID</th>
              <th runat="server">First Name</th>
              <th runat="server">Last Name</th>
            </tr>
            <tr id="itemPlaceholder" runat="server">
            </tr>
          </table>
          <br />
          <asp:DataPager runat="server" ID="ContactsDataPager" PagedControlID="ContactsListView">
            <Fields>
              <asp:NumericPagerField
                ButtonCount="10"
                CurrentPageLabelCssClass="PagerCurrent"
                NextPreviousButtonCssClass="PagerNormal" 
                NumericButtonCssClass="PagerNormal"
                NextPageText=">>"
                PreviousPageText="<<" />
            </Fields>
          </asp:DataPager>
        </LayoutTemplate>
        <ItemTemplate>
          <tr runat="server">
            <td>
              <asp:Label ID="ContactIDLabel" runat="server" Text='<%#Eval("ContactID") %>' />
            </td>
            <td>
              <asp:Label ID="FirstNameLabel" runat="server" Text='<%#Eval("FirstName") %>' />
            </td>
            <td>
              <asp:Label ID="LastNameLabel" runat="server" Text='<%#Eval("LastName") %>' />
            </td>
          </tr>
        </ItemTemplate>
      </asp:ListView>

      <!-- This example uses Microsoft SQL Server and connects      -->
      <!-- to the AdventureWorks sample database. Use an ASP.NET    -->
      <!-- expression to retrieve the connection string value       -->
      <!-- from the Web.config file.                                -->
      <asp:SqlDataSource ID="ContactsDataSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>"
        SelectCommand="SELECT [ContactID], [FirstName], [LastName] FROM Person.Contact">
      </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">
    
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head id="Head1" runat="server">
    <title>NumericPagerField Example</title>
    <style type="text/css">
      .PagerNormal
      {
        font: 9pt Verdana;
        color: #0066CF;
        border: solid 1px #778899;
        padding: 1px 4px;
        text-decoration:none;
      }
      .PagerCurrent
      {
        font: 9pt Verdana;
        border: solid 1px #778899;
        padding: 1px 4px;
        background-color: #FFD700;
      }
    </style>
  </head>
  <body>
    <form id="form1" runat="server">
        
      <h3>NumericPagerField Example</h3>
          
      <asp:ListView ID="ContactsListView" 
        DataSourceID="ContactsDataSource"
        runat="server">
        <LayoutTemplate>        
          <table cellpadding="2" width="640px" border="1" runat="server" id="tblContacts">
            <tr runat="server">
              <th runat="server">ID</th>
              <th runat="server">First Name</th>
              <th runat="server">Last Name</th>
            </tr>
            <tr id="itemPlaceholder" runat="server">
            </tr>
          </table>
          <br />
          <asp:DataPager runat="server" ID="ContactsDataPager" PagedControlID="ContactsListView">
            <Fields>
              <asp:NumericPagerField
                ButtonCount="10"
                CurrentPageLabelCssClass="PagerCurrent"
                NextPreviousButtonCssClass="PagerNormal" 
                NumericButtonCssClass="PagerNormal"
                NextPageText=">>"
                PreviousPageText="<<" />
            </Fields>
          </asp:DataPager>
        </LayoutTemplate>
        <ItemTemplate>
          <tr runat="server">
            <td>
              <asp:Label ID="ContactIDLabel" runat="server" Text='<%# Eval("ContactID") %>' />
            </td>
            <td>
              <asp:Label ID="FirstNameLabel" runat="server" Text='<%# Eval("FirstName") %>' />
            </td>
            <td>
              <asp:Label ID="LastNameLabel" runat="server" Text='<%# Eval("LastName") %>' />
            </td>
          </tr>
        </ItemTemplate>
      </asp:ListView>

      <!-- This example uses Microsoft SQL Server and connects      -->
      <!-- to the AdventureWorks sample database. Use an ASP.NET    -->
      <!-- expression to retrieve the connection string value       -->
      <!-- from the Web.config file.                                -->
      <asp:SqlDataSource ID="ContactsDataSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>"
        SelectCommand="SELECT [ContactID], [FirstName], [LastName] FROM Person.Contact">
      </asp:SqlDataSource>
      
    </form>
  </body>
</html>

Commenti

Utilizzare la ButtonCount proprietà per specificare il numero di pulsanti da visualizzare in un NumericPagerField oggetto. Ogni pulsante corrisponde a un numero di pagina. Se l'oggetto NumericPagerField ha più pagine del numero specificato per ButtonCount, il controllo visualizza un pulsante di pagina successiva che consente agli utenti di accedere al set successivo di pagine.

L'oggetto NumericPagerField visualizza pulsanti solo per i numeri di pagina esistenti. Se l'oggetto NumericPagerField ha meno pagine da visualizzare rispetto al numero specificato per ButtonCount, il controllo mostra meno pulsanti rispetto al numero specificato da questa proprietà.

Si applica a

Vedi anche