Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
GridView Class
 PagerSettings Property
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
GridView..::.PagerSettings Property

Updated: November 2007

Gets a reference to the PagerSettings object that enables you to set the properties of the pager buttons in a GridView control.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

Visual Basic (Declaration)
<PersistenceModeAttribute(PersistenceMode.InnerProperty)> _
Public Overridable ReadOnly Property PagerSettings As PagerSettings
Visual Basic (Usage)
Dim instance As GridView
Dim value As PagerSettings

value = instance.PagerSettings
C#
[PersistenceModeAttribute(PersistenceMode.InnerProperty)]
public virtual PagerSettings PagerSettings { get; }
Visual C++
[PersistenceModeAttribute(PersistenceMode::InnerProperty)]
public:
virtual property PagerSettings^ PagerSettings {
    PagerSettings^ get ();
}
J#
/** @property */
/** @attribute PersistenceModeAttribute(PersistenceMode.InnerProperty) */
public PagerSettings get_PagerSettings()
JScript
public function get PagerSettings () : PagerSettings

Property Value

Type: System.Web.UI.WebControls..::.PagerSettings

A reference to the PagerSettings that enables you to set the properties of the pager buttons in a GridView control.

Use the PagerSettings property to control the settings of the pager row in a GridView control. The pager row is displayed when the paging feature is enabled (by setting the AllowPaging property to true) and contains the controls that allow the user to navigate to the different pages in the control. This property is read-only; however, you can set the properties of the PagerSettings object it returns. The properties can be set declaratively using one of the following methods:

  • Place an attribute in the opening tag of the GridView control in the form Property-Subproperty, where Subproperty is a property of the PagerSettings object (for example, PagerSettings-Mode).

  • Nest a <PagerSettings> element between the opening and closing tags of the GridView control.

The properties can also be set programmatically in the form Property.Subproperty (for example, PagerStyle.Mode). Common settings usually include the pager row's display mode and custom text or images for the navigation controls.

TopicLocation
How to: Enable Default Paging in the GridView Web Server ControlBuilding ASP .NET Web Applications in Visual Studio
How to: Enable Default Paging in the GridView Web Server ControlBuilding ASP .NET Web Applications in Visual Studio

The following example demonstrates how to set the PagerSettings property declaratively. It sets the font and background for the pager row to blue and light blue, respectively.

Visual Basic
<%@ Page language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html  >
  <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>


C#
<%@ Page language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html  >
  <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>


Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker