Click here to Skip to main content
12,828,476 members (48,597 online)
Click here to Skip to main content
Add your own
alternative version


48 bookmarked
Posted 8 Oct 2004

Paging with Repeater control in ASP.NET

, 8 Oct 2004
Rate this:
Please Sign up or sign in to vote.
Paging with Repeater control in ASP.NET.


Repeater and DataList controls offer a quick and flexible means of displaying data on a ASPX page. But they offer no paging functionality built in. The DataGrid control has in-built paging but its structure is more rigid. There are several articles on various ASP.NET Resource Sites that offer solutions, but I'm going to show you how to use the PagedDataSource class.

The PagedDataSource class encapsulates the properties of the DataGrid control that allow it to perform paging. But we can use the class with Repeater and DataList controls to perform paging in much the same way as a DataGrid.

Private Sub Page_Load(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles MyBase.Load
    'Put user code to initialize the page here
    Dim myConnection As New _
    Dim myDA As New SqlClient.SqlDataAdapter("Select * from dtsDefect", _
    myDA.Fill(ds, "t1")
    pageds.DataSource = ds.Tables("t1").DefaultView
    pageds.AllowPaging = True
    pageds.PageSize = 4
    Dim curpage As Integer

    If Not IsNothing(Request.QueryString("Page")) Then
        curpage = Convert.ToInt32(Request.QueryString("Page"))
        curpage = 1
    End If

    pageds.CurrentPageIndex = curpage - 1
    lblCurrpage.Text = "Page: " + curpage.ToString()

    If Not pageds.IsFirstPage Then
        lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath + _
                                       "?Page=" + CStr(curpage - 1)
    End If

    If Not pageds.IsLastPage Then
        lnkNext.NavigateUrl = Request.CurrentExecutionFilePath + _
                                       "?Page=" + CStr(curpage + 1)
    End If

    Repeater1.DataSource = pageds
End Sub


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

India India
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralMy vote of 2 Pin
mbsmbs6-Sep-12 5:53
membermbsmbs6-Sep-12 5:53 
BugDatabase call for each request Pin
Parimal@Cybage26-Jun-12 4:59
memberParimal@Cybage26-Jun-12 4:59 
GeneralMy vote of 5 Pin
hostrajeev21-Sep-11 2:54
memberhostrajeev21-Sep-11 2:54 
GeneralExcellant! Pin
kavitharavi8-Jun-11 19:45
memberkavitharavi8-Jun-11 19:45 
GeneralMy vote of 1 Pin
prakash.kumar.jmd26-Aug-10 3:29
memberprakash.kumar.jmd26-Aug-10 3:29 
GeneralMy vote of 1 Pin
mehran ghainian hasaruye27-Jul-10 2:08
membermehran ghainian hasaruye27-Jul-10 2:08 
GeneralMy vote of 1 Pin
Quiero19-Mar-10 8:48
memberQuiero19-Mar-10 8:48 
GeneralC# version of this and IsLastPage problem Pin
rammi.cz25-Nov-09 0:37
memberrammi.cz25-Nov-09 0:37 
GeneralRe: C# version of this and IsLastPage problem Pin
rammi.cz25-Nov-09 0:51
memberrammi.cz25-Nov-09 0:51 
Generalthx alot..excellent code Pin
Shilpi Singh12-May-09 23:45
memberShilpi Singh12-May-09 23:45 
Generalthanks thanks many thanks Pin
Xmen 1-Feb-09 19:44
member Xmen 1-Feb-09 19:44 
GeneralNice article Pin
Ivan (Zaragoza)14-Dec-08 10:06
memberIvan (Zaragoza)14-Dec-08 10:06 
Generalits excellent--- working fine Pin
Member 28350567-Nov-08 23:52
memberMember 28350567-Nov-08 23:52 
GeneralWorking with querystrings Pin
Dejan]20-Dec-07 11:01
memberDejan]20-Dec-07 11:01 
GeneralGood Info...Needs Work Pin
AKwebmaster30-Oct-07 12:54
memberAKwebmaster30-Oct-07 12:54 
GeneralPaging with Repeater control in ASP.NET Pin
Ganesan S10-Aug-07 0:51
memberGanesan S10-Aug-07 0:51 
QuestionPaging with Repeater control in ASP.NET Pin
Ganesan S28-Jun-07 4:08
memberGanesan S28-Jun-07 4:08 
Generalaccess connection Pin
imperialx14-Apr-07 18:12
memberimperialx14-Apr-07 18:12 
Generaldeclare ds Pin
imperialx14-Apr-07 17:35
memberimperialx14-Apr-07 17:35 
GeneralRe: declare ds Pin
imperialx14-Apr-07 17:59
memberimperialx14-Apr-07 17:59 
Generalthanks thanks thanks Pin
Member #381312128-Mar-07 2:15
memberMember #381312128-Mar-07 2:15 
GeneralThanx Man..! Pin
Rizshaikh25-Feb-07 23:17
memberRizshaikh25-Feb-07 23:17 
Generalshould declare PageDataSource variable first Pin
lym6212-Aug-06 1:00
memberlym6212-Aug-06 1:00 
QuestionWhat t1 in this code please explain Pin
asifmehdi9-Jun-06 22:13
memberasifmehdi9-Jun-06 22:13 
GeneralExcellent piece of work! Pin
Bharti24-Apr-06 5:46
memberBharti24-Apr-06 5:46 
Generalpageds Pin
taher ben taib14-Jun-05 23:40
membertaher ben taib14-Jun-05 23:40 
GeneralRe: pageds Pin
jresins20-Jul-05 17:16
memberjresins20-Jul-05 17:16 
GeneralRe: pageds Pin
Ivan (Zaragoza)14-Dec-08 10:08
memberIvan (Zaragoza)14-Dec-08 10:08 
Generalproblem Pin
ayeletatary8-Mar-05 6:58
memberayeletatary8-Mar-05 6:58 
GeneralRe: problem Pin
aayu17-Mar-05 23:39
memberaayu17-Mar-05 23:39 
GeneralRe: problem Pin
Anonymous25-Mar-05 7:00
sussAnonymous25-Mar-05 7:00 
GeneralRe: problem Pin
aayu27-Mar-05 18:45
memberaayu27-Mar-05 18:45 
GeneralRe: problem Pin
Anonymous28-Mar-05 19:26
sussAnonymous28-Mar-05 19:26 
GeneralRe: problem Pin
Anonymous28-Mar-05 19:38
sussAnonymous28-Mar-05 19:38 
GeneralRe: problem Pin
Anonymous29-Mar-05 14:38
sussAnonymous29-Mar-05 14:38 
GeneralRe: problem Pin
zubairuddin19-Jun-05 20:49
memberzubairuddin19-Jun-05 20:49 
QuestionCan we use any templates when we display data? Pin
gun4boy20-Feb-05 22:36
membergun4boy20-Feb-05 22:36 
AnswerRe: Can we use any templates when we display data? Pin
aayu23-Feb-05 17:45
memberaayu23-Feb-05 17:45 
GeneralRe: Can we use any templates when we display data? Pin
nguyenlinhhaivt17-Sep-06 22:28
membernguyenlinhhaivt17-Sep-06 22:28 
GeneralRe: Can we use any templates when we display data? Pin
nguyenlinhhaivt17-Sep-06 22:41
membernguyenlinhhaivt17-Sep-06 22:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170326.1 | Last Updated 9 Oct 2004
Article Copyright 2004 by pathikhrawal
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid