Paging with Repeater Control

Posted by in ASP.NET category on for Beginner level | Views : 80602 red flag
Rating: 5 out of 5  
 1 vote(s)

Repeater doesn't have an in-built feature of paging. But we can use paging in it by using PagedDataSource class. Let me explain it in details.


The Repeater control is a data-bound control. It uses templates to display data. It lacks the built-in support for paging, editing and sorting. The Repeater control may be bound to a database table, and an XML file. In this control, the content and layout of list items is defined using Templates. Every Repeater must define an ItemTemplate.


There are 5 templates available for a Repeater:

  1. Header Template
  2. ItemTemplate
  3. AlternatingItemTemplate
  4. SeparatorTemplate
  5. FooterTemplate


Let me discuss these templates in details:

HeaderTemplate: It is used to specify an optional header row. It is used to   determine the content and layout of the list header. 

ItemTemplate :It is used to define the content and layout of items within the list.

AlternatingItemTemplate: This template is used for elements that are rendered every second row of data. This allows you to alternate background colors.

SeparatorTemplate: The SeparatorTemplate is rendered between each row.

FooterTemplate: It is used to specify an optional footer row. It is used to determine the content and layout of the list footer.  

All these 5 templates will be placed within the Repeater .

Header Template



Footer Template


Link Buttons

These LinkButtons will be placed outside the Repeater Control.

Pagination in Repeater:

Repeater doesn’t support  Paging directly. But we can implement Paging in Repeater by using PagedDataSource.


This class comes from the System.Data.Web.UI.WebControls namespace, so we need not import any additional namespace to the page.


This class encapsulates the paging related properties of a data-bound control.
Few properties of PagedDataSource class are as follows:

  1. PageSize - This property defines how many records are displayed on a page and  it takes an integer (by default it's set at 10).
  2. AllowPaging - This property determines whether the paging should be turned on or off (Boolean "true" or "false"). By default it is set to "false".
  3. CurrentPageIndex - This gets/sets the current page number. By default it returns 0.
  4. PageCount - Returns the total number of pages that are available.
  5. DataSource - The value of this property will be the source of the data which we want to page.
  6. IsFirstPage - Returns "true" or "false". It  depends on whether the current page is the first page in the series.
  7. IsLastPage -- Returns "true" or "false". It  depends on whether the current page is the last page in the series.

Connection Object and Property Decleration follows:

Code for Page_Load Event

Code written in BringData() method

Here I have created an instance of the PagedDataSource class. In the next line, I had set the DataSource In the following  line  the AllowPaging property is to "true". And on the next line  the PageSize property is set to 3.

Code for Previous/Next Buttons

Contents of the Table tblUser


The output is as follows:

The second page is as follows:
On clicking the NxtPage  Link Button the following output appears. If I click on the PrevPage Link Button we can go the the previous page.


This is all about Repeater Control. Hope u all enjoy reading it. Please provide me feedback on it, if any improvements required.


  • http://articles.
  • http://www.
  • http://www.

Page copy protected against web site content infringement by Copyscape

About the Author

Full Name: Zinnia Sarkar
Member Level:
Member Status: Member
Member Since: 7/24/2010 12:50:40 PM
Country: India
Regards, Ganeshji

Login to vote for this post.

Comments or Responses

Posted by: Nagarajsoft on: 8/10/2010
Nice article..
Posted by: Mspace on: 6/7/2012 | Points: 25

Thank you for you nice article.
I have a problem. I use an updatepanel and I put all the controls inside it. The paging works fine but I would like to bring the first values on page load without the user needs to click on the next button
Thank you

Login to post response

Comment using Facebook(Author doesn't get notification)