NextPreviousPagerField NextPreviousPagerField NextPreviousPagerField NextPreviousPagerField Class

Definition

Represents a field that displays navigation controls in a DataPager control enable users to page through data.

public ref class NextPreviousPagerField : System::Web::UI::WebControls::DataPagerField
public class NextPreviousPagerField : System.Web.UI.WebControls.DataPagerField
type NextPreviousPagerField = class
    inherit DataPagerField
Public Class NextPreviousPagerField
Inherits DataPagerField
Inheritance
NextPreviousPagerFieldNextPreviousPagerFieldNextPreviousPagerFieldNextPreviousPagerField

Examples

The following example shows how to use a NextPreviousPagerField object to page through data that is displayed in a ListView control.

<%@ 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 id="Head1" runat="server">
    <title>NextPreviousPagerField Example</title>
  </head>
  <body>
    <form id="form1" runat="server">
        
      <h3>NextPreviousPagerField Example</h3>
          
      <asp:ListView ID="ContactsListView" 
        DataSourceID="ContactsDataSource"
        runat="server">
        <LayoutTemplate>
          <table cellpadding="2" width="640px" border="1" runat="server" id="tblContacts">
            <tr id="itemPlaceholder" runat="server">
            </tr>
          </table>
        </LayoutTemplate>
        <ItemTemplate>
          <tr runat="server">
            <td>
              <asp:Label ID="ContactIDLabel" runat="server" Text='<%#Eval("ContactID") %>' />
            </td>
            <td>
              <asp:Label ID="FirstNameLabel" runat="server" Text='<%#Eval("FirstName") %>' />
            </td>
            <td>
              <asp:Label ID="LastNameLabel" runat="server" Text='<%#Eval("LastName") %>' />
            </td>
          </tr>
        </ItemTemplate>
      </asp:ListView>

      <asp:DataPager runat="server" ID="ContactsDataPager" PagedControlID="ContactsListView">
        <Fields>
          <asp:NextPreviousPagerField ShowFirstPageButton="true" ShowLastPageButton="true" />
        </Fields>
      </asp:DataPager>

      <!-- This example uses Microsoft SQL Server and connects      -->
      <!-- to the AdventureWorks sample database. Use an ASP.NET    -->
      <!-- expression to retrieve the connection string value       -->
      <!-- from the Web.config file.                                -->
      <asp:SqlDataSource ID="ContactsDataSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>"
        SelectCommand="SELECT [ContactID], [FirstName], [LastName] FROM Person.Contact">
      </asp:SqlDataSource>
      
    </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 id="Head1" runat="server">
    <title>NextPreviousPagerField Example</title>
  </head>
  <body>
    <form id="form1" runat="server">
        
      <h3>NextPreviousPagerField Example</h3>
          
      <asp:ListView ID="ContactsListView" 
        DataSourceID="ContactsDataSource"
        runat="server">
        <LayoutTemplate>
          <table cellpadding="2" width="640px" border="1" runat="server" id="tblContacts">
            <tr id="itemPlaceholder" runat="server">
            </tr>
          </table>
        </LayoutTemplate>
        <ItemTemplate>
          <tr runat="server">
            <td>
              <asp:Label ID="ContactIDLabel" runat="server" Text='<%#Eval("ContactID") %>' />
            </td>
            <td>
              <asp:Label ID="FirstNameLabel" runat="server" Text='<%#Eval("FirstName") %>' />
            </td>
            <td>
              <asp:Label ID="LastNameLabel" runat="server" Text='<%#Eval("LastName") %>' />
            </td>
          </tr>
        </ItemTemplate>
      </asp:ListView>

      <asp:DataPager runat="server" ID="ContactsDataPager" PagedControlID="ContactsListView">
        <Fields>
          <asp:NextPreviousPagerField ShowFirstPageButton="true" ShowLastPageButton="true" />
        </Fields>
      </asp:DataPager>

      <!-- This example uses Microsoft SQL Server and connects      -->
      <!-- to the AdventureWorks sample database. Use an ASP.NET    -->
      <!-- expression to retrieve the connection string value       -->
      <!-- from the Web.config file.                                -->
      <asp:SqlDataSource ID="ContactsDataSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>"
        SelectCommand="SELECT [ContactID], [FirstName], [LastName] FROM Person.Contact">
      </asp:SqlDataSource>
      
    </form>
  </body>
</html>

Remarks

The NextPreviousPagerField class represents a field that displays navigation controls in a DataPager control. These navigation controls can be used to page through data that are displayed by a control that implements the IPageableItemContainer interface, such as the ListView control.

The NextPreviousPagerField class provides buttons that enable users to navigate through the pages of data one page at a time, or to jump to the first or last page of data.

You can customize the appearance of the NextPreviousPagerField object by using the ButtonCssClass property to set the style of the buttons. You can also use the ButtonType property to choose the type of button that is displayed. The following table lists the available button types.

Button type Description
Button A Button control.
Image An ImageButton control.
Link A LinkButton control.

You can hide a NextPreviousPagerField object in a DataPager control by setting the Visible property to false. You can also hide the individual buttons (the first-page, previous-page, next-page, and last-page buttons) by setting the ShowFirstPageButton, ShowPreviousPageButton, ShowNextPageButton, and ShowLastPageButton properties to false.

The NextPreviousPagerField control enables you to specify custom text for each button by using the FirstPageText, PreviousPageText, NextPageText, and LastPageText properties.

When the ButtonType property is set to ButtonType.Image, you must provide the URL to an image that will be displayed for the button. You can set images individually for each button by setting the FirstPageImageUrl, PreviousPageImageUrl, NextPageImageUrl, and LastPageImageUrl properties.

When the ButtonType property is set to ButtonType.Image, the corresponding text property acts as the alternate text for the image. For example, the text that is specified by the FirstPageText property is displayed as the alternate text for the first-page image button. In browsers that support tooltips, this text is also displayed as a tooltip.

Constructors

NextPreviousPagerField() NextPreviousPagerField() NextPreviousPagerField() NextPreviousPagerField()

Initializes a new instance of the NextPreviousPagerField class.

Properties

ButtonCssClass ButtonCssClass ButtonCssClass ButtonCssClass

Gets or sets the cascading style sheet (CSS) class that is used to render the buttons of the pager field on the browser.

ButtonType ButtonType ButtonType ButtonType

Gets or sets the button type to display in the pager field.

DataPager DataPager DataPager DataPager

Gets a reference to the data pager that the DataPagerField object is associated with.

(Inherited from DataPagerField)
FirstPageImageUrl FirstPageImageUrl FirstPageImageUrl FirstPageImageUrl

Gets or sets the URL to an image that is displayed for the first-page button.

FirstPageText FirstPageText FirstPageText FirstPageText

Gets or sets the text that is displayed for the first-page button.

IStateManager.IsTrackingViewState IStateManager.IsTrackingViewState IStateManager.IsTrackingViewState IStateManager.IsTrackingViewState

Gets a value that indicates whether the DataPagerField object is tracking its view-state changes.

(Inherited from DataPagerField)
IsTrackingViewState IsTrackingViewState IsTrackingViewState IsTrackingViewState

Gets a value that indicates whether the DataPagerField object is tracking its view-state changes.

(Inherited from DataPagerField)
LastPageImageUrl LastPageImageUrl LastPageImageUrl LastPageImageUrl

Gets or sets the URL to an image that is displayed for the last-page button in the NextPreviousPagerField object.

LastPageText LastPageText LastPageText LastPageText

Gets or sets the text that is displayed for the last-page button.

NextPageImageUrl NextPageImageUrl NextPageImageUrl NextPageImageUrl

Gets or sets the URL to an image that is displayed for the next-page button in the NextPreviousPagerField object.

NextPageText NextPageText NextPageText NextPageText

Gets or sets the text that is displayed for the next-page button.

PreviousPageImageUrl PreviousPageImageUrl PreviousPageImageUrl PreviousPageImageUrl

Gets or sets the URL to an image that is displayed for the previous-page button in the NextPreviousPagerField object.

PreviousPageText PreviousPageText PreviousPageText PreviousPageText

Gets or sets the text that is displayed for the previous-page button.

QueryStringHandled QueryStringHandled QueryStringHandled QueryStringHandled

Gets or sets a value that indicates whether the query string field has been evaluated.

(Inherited from DataPagerField)
QueryStringValue QueryStringValue QueryStringValue QueryStringValue

Gets the value of the query string field from the URL of the request.

(Inherited from DataPagerField)
RenderDisabledButtonsAsLabels RenderDisabledButtonsAsLabels RenderDisabledButtonsAsLabels RenderDisabledButtonsAsLabels

Gets or sets a value that indicates whether disabled buttons are rendered as Label controls by the NextPreviousPagerField object.

RenderNonBreakingSpacesBetweenControls RenderNonBreakingSpacesBetweenControls RenderNonBreakingSpacesBetweenControls RenderNonBreakingSpacesBetweenControls

Gets or sets a value that indicates whether non-breaking spaces are rendered between controls.

ShowFirstPageButton ShowFirstPageButton ShowFirstPageButton ShowFirstPageButton

Gets or sets a value that indicates whether the first-page button is displayed in a NextPreviousPagerField object.

ShowLastPageButton ShowLastPageButton ShowLastPageButton ShowLastPageButton

Gets or sets a value that indicates whether the last-page button is displayed in a NextPreviousPagerField object.

ShowNextPageButton ShowNextPageButton ShowNextPageButton ShowNextPageButton

Gets or sets a value that indicates whether the next-page button is displayed in a NextPreviousPagerField object.

ShowPreviousPageButton ShowPreviousPageButton ShowPreviousPageButton ShowPreviousPageButton

Gets or sets a value that indicates whether the previous-page button is displayed in a NextPreviousPagerField object.

ViewState ViewState ViewState ViewState

Gets a dictionary of state information that enables you to save and restore the view state of a DataPagerField object across multiple requests for the same page.

(Inherited from DataPagerField)
Visible Visible Visible Visible

Gets or sets a value that indicates whether a data pager field is rendered.

(Inherited from DataPagerField)

Methods

CloneField() CloneField() CloneField() CloneField()

Creates a copy of the current object that is derived from DataPagerField.

(Inherited from DataPagerField)
CopyProperties(DataPagerField) CopyProperties(DataPagerField) CopyProperties(DataPagerField) CopyProperties(DataPagerField)

Copies the properties of the current NextPreviousPagerField object to the specified DataPagerField object.

CreateDataPagers(DataPagerFieldItem, Int32, Int32, Int32, Int32) CreateDataPagers(DataPagerFieldItem, Int32, Int32, Int32, Int32) CreateDataPagers(DataPagerFieldItem, Int32, Int32, Int32, Int32) CreateDataPagers(DataPagerFieldItem, Int32, Int32, Int32, Int32)

Creates the user interface (UI) controls for the pager field object and adds them to the specified container.

CreateField() CreateField() CreateField() CreateField()

Creates and returns a new instance of the NextPreviousPagerField class.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current NextPreviousPagerField object.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as a hash function for the NextPreviousPagerField class.

GetQueryStringNavigateUrl(Int32) GetQueryStringNavigateUrl(Int32) GetQueryStringNavigateUrl(Int32) GetQueryStringNavigateUrl(Int32)

Creates a URL that contains a query string field that has the specified page number.

(Inherited from DataPagerField)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
HandleEvent(CommandEventArgs) HandleEvent(CommandEventArgs) HandleEvent(CommandEventArgs) HandleEvent(CommandEventArgs)

Handles events that occur in the NextPreviousPagerField control and performs the appropriate action.

LoadViewState(Object) LoadViewState(Object) LoadViewState(Object) LoadViewState(Object)

Restores view-state information that was saved previously.

(Inherited from DataPagerField)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
OnFieldChanged() OnFieldChanged() OnFieldChanged() OnFieldChanged()

Raises the FieldChanged event.

(Inherited from DataPagerField)
SaveViewState() SaveViewState() SaveViewState() SaveViewState()

Saves the changes that were made to the DataPagerField object's view state.

(Inherited from DataPagerField)
ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)
TrackViewState() TrackViewState() TrackViewState() TrackViewState()

Causes the DataPagerField object to track changes to its view state so that they can be stored in the control's ViewState property and persisted across requests for the same page.

(Inherited from DataPagerField)

Explicit Interface Implementations

IStateManager.LoadViewState(Object) IStateManager.LoadViewState(Object) IStateManager.LoadViewState(Object) IStateManager.LoadViewState(Object)

Restores view-state information that was saved previously.

(Inherited from DataPagerField)
IStateManager.SaveViewState() IStateManager.SaveViewState() IStateManager.SaveViewState() IStateManager.SaveViewState()

Saves the changes that were made to the DataPagerField object's view state.

(Inherited from DataPagerField)
IStateManager.TrackViewState() IStateManager.TrackViewState() IStateManager.TrackViewState() IStateManager.TrackViewState()

Causes the DataPagerField object to track changes to its view state so that they can be stored in the control's ViewState property and persisted across requests for the same page.

(Inherited from DataPagerField)

Applies to

See also