Bagikan melalui


GridView.PagerSettings Properti

Definisi

Mendapatkan referensi ke PagerSettings objek yang memungkinkan Anda mengatur properti tombol pager dalam GridView kontrol.

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

Nilai Properti

Referensi ke PagerSettings yang memungkinkan Anda mengatur properti tombol pager dalam GridView kontrol.

Atribut

Contoh

Contoh berikut menunjukkan cara mengatur PagerSettings properti secara deklaratif. Ini mengatur font dan latar belakang untuk baris pager ke biru dan biru muda, masing-masing.


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

Keterangan

PagerSettings Gunakan properti untuk mengontrol pengaturan baris pager dalam GridView kontrol. Baris pager ditampilkan ketika fitur halaman diaktifkan (dengan mengatur AllowPaging properti ke true) dan berisi kontrol yang memungkinkan pengguna untuk menavigasi ke halaman yang berbeda dalam kontrol. Properti ini bersifat baca-saja; namun, Anda dapat mengatur properti objek yang PagerSettings dikembalikannya. Properti dapat diatur secara deklaratif menggunakan salah satu metode berikut:

  • Tempatkan atribut dalam tag GridView pembuka kontrol dalam formulir Property-Subproperty, di mana Subproperty adalah properti PagerSettings objek (misalnya, PagerSettings-Mode).

  • Sarangkan <PagerSettings> elemen antara tag GridView pembuka dan penutup kontrol.

Properti juga dapat diatur secara terprogram dalam formulir Property.Subproperty (misalnya, PagerStyle.Mode). Pengaturan umum biasanya mencakup mode tampilan baris pager dan teks atau gambar kustom untuk kontrol navigasi.

Berlaku untuk

Lihat juga