Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

DataGridPagerStyle Class

Specifies the style for the pager of the DataGrid control. This class cannot be inherited.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)
public sealed class DataGridPagerStyle : TableItemStyle

The DataGridPagerStyle type exposes the following members.

  NameDescription
Public propertyBackColorGets or sets the background color of the Web server control. (Inherited from Style.)
Public propertyBorderColorGets or sets the border color of the Web server control. (Inherited from Style.)
Public propertyBorderStyleGets or sets the border style of the Web server control. (Inherited from Style.)
Public propertyBorderWidthGets or sets the border width of the Web server control. (Inherited from Style.)
Public propertyContainerGets the IContainer that contains the Component. (Inherited from Component.)
Public propertyCssClassGets or sets the cascading style sheet (CSS) class rendered by the Web server control on the client. (Inherited from Style.)
Public propertyFontGets the font properties associated with the Web server control. (Inherited from Style.)
Public propertyForeColorGets or sets the foreground color (typically the color of the text) of the Web server control. (Inherited from Style.)
Public propertyHeightGets or sets the height of the Web server control. (Inherited from Style.)
Public propertyHorizontalAlignGets or sets the horizontal alignment of the contents in a cell. (Inherited from TableItemStyle.)
Public propertyIsEmptyInfrastructure. A protected property. Gets a value indicating whether any style elements have been defined in the state bag. (Inherited from Style.)
Public propertyModeGets or sets a value that specifies whether the pager element displays buttons that link to the next and previous page, or numeric buttons that link directly to a page.
Public propertyNextPageTextGets or sets the text displayed for the next page button.
Public propertyPageButtonCountGets or sets the number of numeric buttons to display concurrently in the pager element of the DataGrid control.
Public propertyPositionGets or sets the position of the pager element in the DataGrid control.
Public propertyPrevPageTextGets or sets the text displayed for the previous page button.
Public propertyRegisteredCssClassGets the cascading style sheet (CSS) class that is registered with the control. (Inherited from Style.)
Public propertySiteGets or sets the ISite of the Component. (Inherited from Component.)
Public propertyVerticalAlignGets or sets the vertical alignment of the contents in a cell. (Inherited from TableItemStyle.)
Protected propertyViewStateInfrastructure. Gets the state bag that holds the style elements. (Inherited from Style.)
Public propertyVisibleGets or sets a value indicating whether the pager is displayed in the DataGrid control.
Public propertyWidthGets or sets the width of the Web server control. (Inherited from Style.)
Public propertyWrapGets or sets a value indicating whether the contents of a cell wrap in the cell. (Inherited from TableItemStyle.)
Top
  NameDescription
Public methodAddAttributesToRender(HtmlTextWriter)Adds HTML attributes and styles that need to be rendered to the specified System.Web.UI.HtmlTextWriter. This method is primarily used by control developers. (Inherited from Style.)
Public methodAddAttributesToRender(HtmlTextWriter, WebControl)Adds information about horizontal alignment, vertical alignment, and wrap to the list of attributes to render. (Inherited from TableItemStyle.)
Public methodCopyFromCopies the style of the specified Style object into this instance of the DataGridPagerStyle class. (Overrides TableItemStyle.CopyFrom(Style).)
Public methodCreateObjRefCreates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.)
Public methodDispose()Releases all resources used by the Component. (Inherited from Component.)
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetLifetimeServiceRetrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Public methodGetStyleAttributesRetrieves the System.Web.UI.CssStyleCollection object for the specified System.Web.UI.IUrlResolutionService-implemented object. (Inherited from Style.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodInitializeLifetimeServiceObtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Protected methodLoadViewStateLoads the previously saved state. (Inherited from Style.)
Public methodMergeWithMerges the style of the specified Style object with this instance of the DataGridPagerStyle class. (Overrides TableItemStyle.MergeWith(Style).)
Public methodResetRestores the DataGridPagerStyle object to its default values. (Overrides TableItemStyle.Reset().)
Protected methodSaveViewStateA protected method. Saves any state that has been modified after the TrackViewState method was invoked. (Inherited from Style.)
Protected methodSetBitInfrastructure. A protected internal method. Sets an internal bitmask field that indicates the style properties that are stored in the state bag. (Inherited from Style.)
Public methodSetDirtyMarks the Style so that its state will be recorded in view state. (Inherited from Style.)
Public methodToStringReturns a String containing the name of the Component, if any. This method should not be overridden. (Inherited from Component.)
Protected methodTrackViewStateA protected method. Marks the beginning for tracking state changes on the control. Any changes made after tracking has begun will be tracked and saved as part of the control view state. (Inherited from Style.)
Top
  NameDescription
Public eventDisposedOccurs when the component is disposed by a call to the Dispose method. (Inherited from Component.)
Top
  NameDescription
Explicit interface implemetationPrivate propertyIStateManager.IsTrackingViewStateGets a value that indicates whether a server control is tracking its view state changes. (Inherited from Style.)
Explicit interface implemetationPrivate methodIStateManager.LoadViewStateInfrastructure. Loads the previously saved state. (Inherited from Style.)
Explicit interface implemetationPrivate methodIStateManager.SaveViewStateInfrastructure. Returns the object containing state changes. (Inherited from Style.)
Explicit interface implemetationPrivate methodIStateManager.TrackViewStateInfrastructure. Starts tracking state changes. (Inherited from Style.)
Top

The pager is an element on the DataGrid control that allows you to link to other pages when paging is enabled. The PagerStyle property of the DataGrid control uses an instance of this class to represent the style properties for the pager.

For more information on paging, see AllowPaging and AllowCustomPaging.

The following code example demonstrates how to use a DataGridPagerStyle object to represent the style of the pager element in the PagerStyle property. The DataGridPagerStyle object sets the display mode and alignment of the paging element.

<%@ Page Language="C#" AutoEventWireup="True" %>
<%@ Import Namespace="System.Data" %>

<!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" >
   <script language="C#" runat="server">

      ICollection CreateDataSource() 
      {
         DataTable dt = new DataTable();
         DataRow dr;

         dt.Columns.Add(new DataColumn("IntegerValue", typeof(Int32)));
         dt.Columns.Add(new DataColumn("StringValue", typeof(string)));
         dt.Columns.Add(new DataColumn("DateTimeValue", typeof(string)));
         dt.Columns.Add(new DataColumn("BoolValue", typeof(bool)));

         for (int i = 0; i < 100; i++) 
         {
            dr = dt.NewRow();

            dr[0] = i;
            dr[1] = "Item " + i.ToString();
            dr[2] = DateTime.Now.ToShortDateString();
            dr[3] = (i % 2 != 0) ? true : false;

            dt.Rows.Add(dr);
         }

         DataView dv = new DataView(dt);
         return dv;
      }

      void Page_Load(Object sender, EventArgs e) 
      {
         if (chk1.Checked)
            MyDataGrid.PagerStyle.Mode = PagerMode.NumericPages;
         else 
            MyDataGrid.PagerStyle.Mode = PagerMode.NextPrev;

         BindGrid();
      }

      void MyDataGrid_Page(Object sender, DataGridPageChangedEventArgs e) 
      {
         MyDataGrid.CurrentPageIndex = e.NewPageIndex;
         BindGrid();
      }

      void BindGrid() 
      {
         MyDataGrid.DataSource = CreateDataSource();
         MyDataGrid.DataBind();
         ShowStats();
      }

      void ShowStats() 
      {
         lblEnabled.Text = "AllowPaging is " + MyDataGrid.AllowPaging;
         lblCurrentIndex.Text = "CurrentPageIndex is " + MyDataGrid.CurrentPageIndex;
         lblPageCount.Text = "PageCount is " + MyDataGrid.PageCount;
         lblPageSize.Text = "PageSize is " + MyDataGrid.PageSize;
      }


   </script>

<head runat="server">
    <title>Paging with DataGrid</title>
</head>
<body>

   <h3>Paging with DataGrid</h3>

   <form id="form1" runat="server">

      <asp:DataGrid id="MyDataGrid" runat="server"
           AllowPaging="True"
           PageSize="10"
           PagerStyle-Mode="NumericPages"
           PagerStyle-HorizontalAlign="Right"
           OnPageIndexChanged="MyDataGrid_Page"
           BorderColor="black"
           BorderWidth="1"
           GridLines="Both"
           CellPadding="3"
           CellSpacing="0"
           Font-Names="Verdana"
           Font-Size="8pt"
           HeaderStyle-BackColor="#aaaadd"
           AlternatingItemStyle-BackColor="#eeeeee"/>

      <br />

      <asp:Checkbox id="chk1" runat="server"
           Text="Show numeric page navigation buttons"
           Font-Names="Verdana"
           Font-Size="8pt"
           AutoPostBack="true"/>

      <br />

      <table style="background-color:#eeeeee; padding:6">
         <tr>
            <td style="display:inline">


                  <asp:Label id="lblEnabled" 
                       runat="server"/><br />
                  <asp:Label id="lblCurrentIndex" 
                       runat="server"/><br />
                  <asp:Label id="lblPageCount" 
                       runat="server"/><br />
                  <asp:Label id="lblPageSize" 
                        runat="server"/><br />


            </td>
         </tr>
      </table>

   </form>

</body>
</html>

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.