GridView.PagerStyle 屬性

定義

取得 TableItemStyle 物件的參考,其可讓您設定 GridView 控制項之頁面巡覽區資料列的外觀。

public:
 property System::Web::UI::WebControls::TableItemStyle ^ PagerStyle { System::Web::UI::WebControls::TableItemStyle ^ get(); };
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
public System.Web.UI.WebControls.TableItemStyle PagerStyle { get; }
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
member this.PagerStyle : System.Web.UI.WebControls.TableItemStyle
Public ReadOnly Property PagerStyle As TableItemStyle

屬性值

TableItemStyle 的參考,表示 GridView 控制項中頁面巡覽列的樣式。

屬性

範例

下列範例示範如何以宣告方式設定 PagerStyle 屬性。 它會分別將頁面巡覽列的字型和背景設定為藍色和淺藍色。


<%@ 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 runat="server">
    <title>GridView AllowPaging Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>GridView AllowPaging Example</h3>

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSource" 
        autogeneratecolumns="true"
        emptydatatext="No data available." 
        allowpaging="true" 
        runat="server">
                
        <pagersettings mode="Numeric"
          position="Bottom"           
          pagebuttoncount="10"/>
                      
        <pagerstyle backcolor="LightBlue"
          height="30px"
          verticalalign="Bottom"
          horizontalalign="Center"/>
                
      </asp:gridview>
            
      <!-- 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="CustomersSource"
        selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]"
        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">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>GridView AllowPaging Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>GridView AllowPaging Example</h3>

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSource" 
        autogeneratecolumns="true"
        emptydatatext="No data available." 
        allowpaging="true" 
        runat="server">
                
        <pagersettings mode="Numeric"
          position="Bottom"           
          pagebuttoncount="10"/>
                      
        <pagerstyle backcolor="LightBlue"
          height="30px"
          verticalalign="Bottom"
          horizontalalign="Center"/>
                
      </asp:gridview>
            
      <!-- 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="CustomersSource"
        selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" 
        runat="server"/>
        
    </form>
  </body>
</html>

備註

PagerStyle使用 屬性來控制 控制項中 GridView 呼叫器資料列的外觀。 藉由將 屬性 true 設定 AllowPaging 為) ,並包含可讓使用者巡覽至控制項中不同頁面的控制項,即可顯示分頁功能 (。 此屬性是唯讀的;不過,您可以設定其傳回之 TableItemStyle 物件的屬性。 您可以使用下列其中一種方法,以宣告方式設定屬性:

  • 將 屬性放在 控制項的 GridView 開頭標記中,其中 Subproperty 是 物件的屬性 TableItemStyle (,例如, PagerStyle-ForeColorProperty-Subproperty) 。

  • <PagerStyle>在控制項的 GridView 開頭和結束記號之間巢狀專案。

屬性也可以在表單 Property.Subproperty 中以程式設計方式設定,例如, PagerStyle.ForeColor) (。 一般設定通常包含自訂背景色彩、前景色彩和字型屬性。

適用於

另請參閱