asp.net.ph

Skip Navigation Links

Specifying Paging Behavior in a GridView Control

Controls You Can Use on Web Forms   ASP.NET Data Controls   GridView Control


The GridView Web server control enables paging thru the data in the grid using any of the following methods:

  • Default paging using built-in paging controls
  • Default paging using custom navigation controls
  • Custom paging

To specify default paging using the built-in paging controls

  1. Set the control’s AllowPaging property to true.
  2. Optionally set the PageSize property to the number of rows to display per page. If not specified, defaults to 10 rows per page.
<asp:GridView id="myGrid" runat="server"
   datasourceid="customers"
   allowpaging=true
   ...
>

or simply

<asp:GridView id="myGrid" runat="server"
   datasourceid="customers"
   allowpaging
   ...
>
GridView with Default Paging
Run Sample | View Source

The GridView control includes properties for customizing the default pager style.

To set the behavior and appearance of the pager buttons

  1. Within the GridView declaration, declare a <PagerSettings> element.
  2. Within the PagerSettings element, define each of the properties you intend to customize. For syntax, see GridView Control Syntax.
    <pagersettings
          mode="nextprevious"
          nextpagetext="Next" 
          previouspagetext="Back" 
          position="top"
          pagebuttoncount=10 />
  3. Also within the GridView declaration, declare a <PagerStyle> element.
  4. Within the PagerStyle element, define each of the properties you intend to customize. For syntax, see GridView Control Syntax.
    <pagerstyle
          backcolor="steelblue" 
          forecolor="beige"
          horizontalalign="right" />
GridView PagerSettings, PagerStyle Example
Run Sample | View Source



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note