---
title: Implementing the IUniPageable interface
---

> 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 following is a step-by-step tutorial shows how to create a custom control that displays users and implements the **IUniPageable** interface. This allows the control to be paged by the [UniPager](https://docs.kentico.com/k10/references/kentico-controls/generic-controls/paging-controls/unipager.md).

1. Create a new **Web User Control** in your web project (the example uses the name _UniPageable\_Repeater.ascx_).
2. Add the following markup to the user control:

   ```html

   <asp:Repeater ID="Repeater1" runat="server">

       <ItemTemplate>

       <div>
           <%# Eval("UserName") %>
       </div>

       </ItemTemplate>

   </asp:Repeater>

   ```

   > **Info:** This adds a standard .NET Repeater control that will be used to display user names.
3. Switch to the code behind of the control and add the following code.

   > **Note:** **Note**: The name of the class must match the name and location of your web user control.

   ```csharp

   using CMS.DocumentEngine.Web.UI;
   using CMS.Membership;

   public partial class IUniPageableExample_UniPageable_Repeater : System.Web.UI.UserControl, IUniPageable
   {
       // Private variable containing the value of the PagerForceNumberOfResults property
       private int mPagerForceNumberOfResults = -1;

       // Private variable used to contain the data source of the control
       private object dataSource = null;

       // Private variable storing the associated UniPager object
       private UniPager mUniPagerControl = null;

       protected void Page_Load(object sender, EventArgs e)
       {
           // Loads all users from the database into the data source
           dataSource = UserInfoProvider.GetUsers();

           // Calls the page binding event
           if (OnPageBinding != null)
           {
               OnPageBinding(this, null);
           }

           // Assigns the data source to the encapsulated Repeater control
           Repeater1.DataSource = dataSource;
           Repeater1.DataBind();
       }

       /// <summary>
       /// Occurs when the control binds page data
       /// </summary>
       public event EventHandler<EventArgs> OnPageBinding;

       /// <summary>
       /// Occurs when the pager changes the page and the current PagerMode is set to postback
       /// </summary>
       public event EventHandler<EventArgs> OnPageChanged;

       /// <summary>
       /// Exposes the data object for the pager
       /// </summary>
       public object PagerDataItem
       {
           get
           {
               return dataSource;
           }
           set
           {
               dataSource = value;
               Repeater1.DataSource = value;
           }
       }

       /// <summary>
       /// If set, the DataSet containing paged items is not modified by the pager, 
       /// but the pager itself behaves as if the amount of paged items were identical to this value.
       /// By default this property is disabled (set to -1)
       /// </summary>
       public int PagerForceNumberOfResults
       {
           get
           {
               return mPagerForceNumberOfResults;
           }
           set
           {
               mPagerForceNumberOfResults = value;
           }
       }

       /// <summary>
       /// Gets or sets the pager control.
       /// </summary>
       public UniPager UniPagerControl
       {
           get
           {
               return mUniPagerControl;
           }
           set
           {
               mUniPagerControl = value;
           }
       }

       /// <summary>
       /// Evokes databinding for the control
       /// </summary>
       public void ReBind()
       {
           if (OnPageChanged != null)
           {
               OnPageChanged(this, null);
           }
           Repeater1.DataBind();
       }
   }

   ```
4. Save the user control's files.
   - The control now implements the _IUniPageable_ interface and is pageable by the _UniPager_ control.
5. Create a new **Web form** somewhere in your web project.
6. Register your custom control on the web form:

   ```html

   <%@ Register src="~/IUniPageableExample/UniPageable_Repeater.ascx" tagname="UniPageableRepeater" tagprefix="asp1" %>

   ```
7. Add the following code into the content area of the page (by default between the **** tags inside the **** element):

   ```html

   <asp1:UniPageableRepeater ID="UPRepeater1" runat="server" />

   <cms:UniPager ID="UniPager1" runat="server" PageControl="UPRepeater1" PageSize="5">

       <PageNumbersTemplate>
           <a href="<%# Eval("PageURL") %>"><%# Eval("Page") %></a>
       </PageNumbersTemplate>  

   </cms:UniPager>

   ```
8. Save the web form.
9. Right-click the web form in the Solution explorer and select **View in Browser**.

The resulting page displays a list of user names with a basic pager:

![](https://docs.kentico.com/docsassets/k10/implementing-the-iunipageable-interface/image.png)
