aspdotnet-suresh offers articles and tutorials,csharp dot net, articles and tutorials,VB.NET Articles,Gridview articles,code examples of 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

Asp.Net Repeater with Paging Example in C#, VB.NET

Jun 30, 2016

Here I will explain how to implement paging in repeater control in using c#, with example or repeater with paging in c#, or pagination in repeater control with example in c#, To implement paging in repeater control we need to write custom logic because we don’t have any properties available for enabling pagination for repeater control.

To implement pagination in repeater control in using c#, first write the code following code in your aspx page

<html xmlns="">
<head id="Head1" runat="server">
<title>Asp.Net Repeater Control with Paging in C#, VB.NET</title>
<form id="form1" runat="server">
<asp:Repeater ID="rptUserData" runat="server">
<table id="tbDetails" style="width:500px; border-collapse: collapse;" border="1" cellpadding="5" cellspacing="0" >
<tr style="background-color: #df5015; height: 30px; color:#fff" align="left">
<tr style="height: 25px;">
<td >
<td >
</div><br />
<asp:Repeater ID="rptPaging" runat="server" onitemcommand="rptPaging_ItemCommand">
<asp:LinkButton ID="lnkPage"
style="padding:8px; margin:2px; background:#B34C00; border:solid 1px #666; color:#fff; font-weight:bold"
CommandName="Page" CommandArgument="<%# Container.DataItem %>"
runat="server" Font-Bold="True"><%# Container.DataItem %>

Now open code behind file and write following code

C# Code

using System;
using System.Collections;
using System.Data;
using System.Web.UI.WebControls;

public partial class RepeaterwithPaging : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
if (!IsPostBack)
// Binding Repeater Control with Paging
private void BindRepeater()
DataTable dt = new DataTable();
dt.Columns.Add("UserId", typeof(Int32));
dt.Columns.Add("UserName", typeof(string));
dt.Columns.Add("Education", typeof(string));
dt.Rows.Add(1, "Suresh Dasari", "B.Tech");
dt.Rows.Add(2, "Rohini Dasari", "Msc");
dt.Rows.Add(3, "Madhav Sai", "MS");
dt.Rows.Add(4, "Praveen", "B.Tech");
dt.Rows.Add(6, "Sateesh", "MD");
dt.Rows.Add(7, "Mahesh Dasari", "B.Tech");
dt.Rows.Add(8, "Mahendra", "CA");
PagedDataSource pageds = new PagedDataSource();
DataView dv = new DataView(dt);
pageds.DataSource = dv;
pageds.AllowPaging = true;
pageds.PageSize = 3;
if (ViewState["PageNumber"] != null)
pageds.CurrentPageIndex = Convert.ToInt32(ViewState["PageNumber"]);
pageds.CurrentPageIndex = 0;
if (pageds.PageCount > 1)
rptPaging.Visible = true;
ArrayList pages = new ArrayList();
for (int i = 0; i < pageds.PageCount; i++)
pages.Add((i + 1).ToString());
rptPaging.DataSource = pages;
rptPaging.Visible = false;
rptUserData.DataSource = pageds;
// Binding Data on Page Item Change
protected void rptPaging_ItemCommand(object source, RepeaterCommandEventArgs e)
ViewState["PageNumber"] = Convert.ToInt32(e.CommandArgument) - 1;


Imports System.Collections
Imports System.Data
Imports System.Web.UI.WebControls

Partial Class VBCode
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not IsPostBack Then
End If
End Sub
' Binding Repeater with Paging
Private Sub BindRepeater()
Dim dt As New DataTable()
dt.Columns.Add("UserId", GetType(Int32))
dt.Columns.Add("UserName", GetType(String))
dt.Columns.Add("Education", GetType(String))
dt.Rows.Add(1, "Suresh Dasari", "B.Tech")
dt.Rows.Add(2, "Rohini Dasari", "Msc")
dt.Rows.Add(3, "Madhav Sai", "MS")
dt.Rows.Add(4, "Praveen", "B.Tech")
dt.Rows.Add(6, "Sateesh", "MD")
dt.Rows.Add(7, "Mahesh Dasari", "B.Tech")
dt.Rows.Add(8, "Mahendra", "CA")
Dim pageds As New PagedDataSource()
Dim dv As New DataView(dt)
pageds.DataSource = dv
pageds.AllowPaging = True
pageds.PageSize = 3
If ViewState("PageNumber") IsNot Nothing Then
pageds.CurrentPageIndex = Convert.ToInt32(ViewState("PageNumber"))
pageds.CurrentPageIndex = 0
End If
If pageds.PageCount > 1 Then
rptPaging.Visible = True
Dim pages As New ArrayList()
For i As Integer = 0 To pageds.PageCount - 1
pages.Add((i + 1).ToString())
rptPaging.DataSource = pages
rptPaging.Visible = False
End If
rptUserData.DataSource = pageds
End Sub
' Binding Data on Page Item Change
Protected Sub rptPaging_ItemCommand(ByVal source As Object, ByVal e As RepeaterCommandEventArgs)
ViewState("PageNumber") = Convert.ToInt32(e.CommandArgument) - 1
End Sub
End Class


If you enjoyed this post, please support the blog below. It's FREE!

Get the latest,, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email


mounika Mouni said...


Give your Valuable Comments

Other Related Posts

© 2015 All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.