Page navigation bars

As an alternative to setting the RowsPerPage property and creating your own user interface for navigating between pages, you can use an integrated page navigation bar. The page navigation bar can be added to the top or bottom of the DataWindow and can use several different styles.

The PageNavigationBarSettings property, which is an instance of the PageNavigationBarSettings class, lets you control the visibility, style, page navigation mode, and other properties of the page navigation bar. You set these options in the PageNavigationBarSettings section in the Properties window for the WebDataWindowControl or in code.

To display the page navigation bar, set its Visible property to true and the WebDataWindowControl’s RowsPerPage property to a number greater than 0.

The default page navigator is the NextPrev style. This sample uses the default text-based arrow keys. You can use images or text instead:

The image shows the default arrows used for the NextPrev style.

There are two other basic styles: Numeric and QuickGo. You can combine the QuickGo style with either the NextPrev or Numeric styles. This sample uses Numeric with QuickGo:

The image shows a numeric and quickgo navigator bar.

Table 9-5 lists the properties of PageNavigationBarSettings.

Table 9-5: PageNavigationBarSettings properties

Property

Description

BarStyle

Represents the style of the page navigation bar. PageNavigationBarStyle is a class inherited from the standard System.Web.UI.WebControls.Style, which has all the behaviors and properties of standard System.Web.UI.WebControls.Style.

Use the BarStyle property to control the appearance of the page navigation bar, such as the background color and border style. This property is read-only, however, you can set the properties of the PageNavigationBarStyle object it returns.

NavigatorType

Specifies the navigator type:

  • NextPrev – Previous, next, first, and last page images or text.

  • Numeric – Numbered and first and last page links.

  • QuickGo – A page number input edit box or page number selection drop-down list.

  • NextPrevWithQuickGo – Combined type.

  • NumericWithQuickGo – Combined type.

The default is NextPrev.

NextPrevNavigator

Sets properties of the NextPrev type, such as the URL for the image or the text to use for each of the links and tooltip text for each link.

NumericNavigator

Sets properties of the Numeric type, such as the URL for the image or the text to use for each of the links, tooltip text for each link, and the format for the page number.

PageStatusInfo

Sets the visibility and appearance of current page status information, such as Page 3 of 10, in the page navigation bar.

Position

Indicates the position of the page navigation bar in the WebDataWindowControl: Top, Bottom, or TopAndBottom. The default is Bottom.

QuickGoNavigator

Sets properties of the QuickGo type, such as the URL for the image or the text for the GoTo button, tooltip text, and the format for the page number.

Visible

A boolean value indicating whether the page navigation bar is displayed in the WebDataWindowControl. If the RowsPerPage property of WebDataWindowControl is less than or equal to 0, the page navigation bar does not display when Visible is set to true because there is no paging. The default value is false.

For a description of the properties for the NavigatorTypes, BarStyle, and PageStatusInfo, see the online Help in Visual Studio .NET or the dwref20.chm compiled HTML Help file. Most of these properties are self-explanatory, but a few are described here.

URLs for images

Each of the navigator types has at least one property you can use to specify an image for a button. For example, the following statement in a code-behind file specifies an image for the Next button in a NextPrev style navigator:

dw_1.PageNavigationBarSettings.NextPrevNavigator.NextPageImageUrl = "PageNext.gif"

PageCountPerGroup

For the Numeric type, the PageCountPerGroup property is an integer that indicates the number of numeric buttons to display concurrently in the page navigator. If there are more pages in the WebDataWindowControl than specified in this property, Next or Previous Group Page buttons or both are displayed. For example, if there are 10 pages in the DataWindow and this property is set to three, when the page first displays, the numbers 1, 2, and 3 and the NextGroup button displays. When you click the Next Group button, the

PageNumberDisplay Format

The PageNumberDisplayFormat property for the Numeric and QuickGo types is a string value containing the format used to generate the numeric page number button text. For QuickGo, this property takes effect when the QuickGoPageNavigatorSettings.Type is set to DropDownList and the Mode property is set to PagerMode.NumericPages.

In the page number display format, {P} is the keyword for generating numeric page number button text. For example, if the PageNumberDisplayFormat is #{P}, then the numeric page number button text will be shown as #1, #2. When PageNumberDisplayFormat is an empty string, which is the default value, the format [{P}] is used.

TextFormat

The TextFormat property for PageStatus is a string value used to generate page status text information displayed in the page navigation bar. It uses the following keywords:

Keyword

Generates

{C}

Current page number

{T}

Page count

{R}

Row count

{F}

First row of current page

{L}

Last row of current page

{S}

Starting page of current numeric group

{E}

Ending page of current numeric group

For example, if the TextFormat is Page {C} of {T} (the default), the WebDataWindowControl has 10 pages, and the current page number is 3, the page status information text is generated as Page 3 of 10.