---
title: DataPager
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

The DataPager control can ensure paging for the following CMSControls:

- [CMSDataList](https://docs.kentico.com/k9/references/kentico-controls/cms-controls/cms-controls-listings-and-viewers/cmsdatalist.md)
- [CMSRepeater](https://docs.kentico.com/k9/references/kentico-controls/cms-controls/cms-controls-listings-and-viewers/cmsrepeater.md)
- [CMSSearchResults](https://docs.kentico.com/k9/references/kentico-controls/cms-controls/sql-search-controls/cmssearchresults.md)
- [QueryDataList](https://docs.kentico.com/k9/references/kentico-controls/cms-controls/cms-controls-listings-and-viewers-with-custom-queries/querydatalist.md)
- [QueryRepeater](https://docs.kentico.com/k9/references/kentico-controls/cms-controls/cms-controls-listings-and-viewers-with-custom-queries/queryrepeater.md)

You do not need to use the DataPager separately, it is built into the above controls. You can enable or disable the DataPager though the **EnablePaging** property.

> **Note:** **Note**: If possible, it is recommended to use the newer [UniPager](https://docs.kentico.com/k9/references/kentico-controls/generic-controls/paging-controls/unipager.md) control instead.

## Getting started

The following is a step-by-step tutorial that shows how to use the DataPager control with a CMSRepeater control that displays all pages (menu items) in the system:

1. Create a new **Web form** somewhere in your web project.
2. Drag the **CMSRepeater** control from the toolbox onto the form.
3. Set the following properties for the CMSRepeater:

   - **Path:** /%
   - **ClassNames**: cms.menuitem
   - **EnablePaging**: True

> **Info:** This tells the CMSRepeater which page types to read and enables the DataPager.

4. Add the code marked by the **CMSRepeater templates** comments between the __ tags. The overall code of the CMSRepeater control should look like this:

   ```html

   <cms:CMSRepeater ID="CMSRepeater1" runat="server" Path="/%" ClassNames="cms.menuitem" EnablePaging="true" >

       <%-- CMSRepeater templates ---------------------------------------------------------- --%>                

           <ItemTemplate>
              <%# HTMLHelper.HTMLEncode( Convert.ToString(Eval("NodeAliasPath"))) %>
           </ItemTemplate>
           <AlternatingItemTemplate>
              <font color="#999999">
                   <%# HTMLHelper.HTMLEncode( Convert.ToString(Eval("NodeAliasPath"))) %>    
              </font>
           </AlternatingItemTemplate>
           <SeparatorTemplate>
              <br />
           </SeparatorTemplate>

       <%-- CMSRepeater templates ---------------------------------------------------------- --%>

   </cms:CMSRepeater>

   ```

   > **Info:** This sets the templates used by the CMSRepeater to display the pages (menu items). The control dynamically replaces the __ tags with values of the currently displayed record. This is then repeated for every record in the data source.
5. Save the web form.
6. Right-click the web form in the Solution explorer and select **View in Browser**.

The control displays a pager under the list:

![](https://docs.kentico.com/docsassets/k9/datapager/datapager.png)

## Configuration

You can access the properties of the DataPager through the **PagerControl** property of the connected listing control, for example:

```csharp

CMSRepeater1.PagerControl.BackText = "<-";

```

| Common pager control properties | Description                                        |
| ------------------------------- | -------------------------------------------------- |
| CurrentPage                     | The current page number.                           |
| MaxPages                        | Maximum number of pages that the control displays. |
| PageCount                       | The current number of pages (read only).           |
| PageSize                        | The number of displayed items per page.            |

| DataPager properties | Description                                                                                                                             | Sample value                           |
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------- |
| DataSource           | Can be used to access the object of the pager's data source.                                                                            |                                        |
| BackNextDisplay      | Back/Next display mode.                                                                                                                 | "Buttons"<br>"Hyperlinks"              |
| BackNextLocation     | Back/Next location.                                                                                                                     | "Right"<br>"Left"<br>"Split"<br>"None" |
| BackText             | Back button/hyperlink text.                                                                                                             |                                        |
| FirstText            | First button/hyperlink text.                                                                                                            |                                        |
| HideOnSinglePage     | If true, the pager is hidden if only one page is displayed.                                                                             |                                        |
| IgnoreQueryString    | Indicates whether querystring parameters should be ignored.                                                                             |                                        |
| InsertKeys           | Adds keys to the querystring.                                                                                                           |                                        |
| InsertToUrl          | Indicates whether inserting querystring keys is enabled.                                                                                |                                        |
| LabelText            | Label text.                                                                                                                             |                                        |
| LastText             | Last text.                                                                                                                              |                                        |
| NextText             | Next button/hyperlink text.                                                                                                             |                                        |
| PagedData            | Gets the data to be paged.                                                                                                              |                                        |
| PageNumbersDisplay   | Page numbers display mode.                                                                                                              | "Numbers"<br>"Results"                 |
| PagerPosition        | The position of the pager relative to the paged data.                                                                                   | "Bottom"<br>"Top"<br>"TopAndBottom"    |
| PagingMode           | Determines the type of the used paging parameter. It can either be passed through the URL (QueryString) or through postback (PostBack). | "PostBack"<br>"QueryString"            |
| QueryStringKey       | Query parameter name for the page index.                                                                                                | "pagenumber"                           |
| RecordEnd            | Index of the last record on the current page.                                                                                           |                                        |
| RecordStart          | Index of the first record on the current page.                                                                                          |                                        |
| RemoveFromUrl        | Indicates whether removing querystring keys is enabled.                                                                                 |                                        |
| RemoveKeys           | Removes keys from the querystring.                                                                                                      |                                        |
| ResultsFormat        | Results text format.                                                                                                                    | "Displaying results {0}-{1} (of {2})"  |
| ResultsLocation      | Results location.                                                                                                                       | "Top"<br>"Bottom"<br>"None"            |
| ShowFirstLast        | Indicates whether first/last buttons should be displayed.                                                                               |                                        |
| ShowLabel            | Indicates whether labels should be displayed.                                                                                           |                                        |
| ShowPageNumbers      | Indicates whether page numbers should be displayed.                                                                                     |                                        |
| SliderSize           | Slider size.                                                                                                                            |                                        |
| TotalRecords         | Total amount of data source records.                                                                                                    |                                        |
| UseSlider            | Indicates whether the slider should be used.                                                                                            |                                        |

## Appearance and styling

You can modify the appearance of the DataPager through the following properties or the CSS classes that they specify:

| DataPager property    | Description                                |
| --------------------- | ------------------------------------------ |
| BackNextButtonStyle   | Back/Next button style.                    |
| BackNextLinkSeparator | Back/Next link separator.                  |
| BackNextStyle         | Back/Next style.                           |
| ControlCssClass       | CSS class of the pager control.            |
| LabelStyle            | Label style.                               |
| PageNumbersStyle      | Page numbers style.                        |
| PageNumbersSeparator  | Page numbers separator.                    |
| PagerControlStyle     | Pager control style.                       |
| PagerHTMLAfter        | HTML code to be rendered after the pager.  |
| PagerHTMLBefore       | HTML code to be rendered before the pager. |
| PagerNumberAreaClass  | CSS class of the number area.              |
| ResultsStyle          | Results style.                             |
| SectionPadding        | Section padding.                           |
| SelectedClass         | CSS class of the selected page.            |
| UnselectedClass       | CSS class of unselected pages.             |
