Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Paging a Repeater using an additional component

0.00/5 (No votes)
20 Jun 2007 1  
A component that provides advanced way of data pagination with Repeater as renderring mechanism

Introduction

Programmers often face a problem how to display list of items to the user. There are several components integrated in framework such as datagrid, gridview that can do this work. But as you certainly know, the html output generated by this classes is quite "messy" and is unable to be modified in some easy way. The best known way is writing your custom css adapter in asp.net 2.0, but this is quite hard and doesnt give you a tool of changing pagers itself. Because of that I decided to write my custom component that provides this functionality hand in hand with repeater, that doesn't render more html than you define in templates.

RepeaterPager functionality

The paging functionality lays in Pager itself so when you're binding data you must provide it to the Pager, that processes the data and gives it to the repeater, which simply displays it.

Important attributes that you should know before using it are:

Templates
-there are many templates you can define such as NumericPagerTemplate, SelectedNumericPagerTemplate, Next and Previous PagerTemplate and so on. By setting template content the output html is all under your control.

MaxNumericPagers
- maximal count of displayed numeric pagers

PagersType
- type of pagers that are renderred by Pager, there are these options avaliable: OnlyWords, OnlyNumeric, NumbersBetweenWords, NumbersBehindWords, NumbersBeforeWords

PagingType
- is a system that gives a programmer two options of delivering data to the Pager. First is classic and second is VirualItems that supports only giving a data of current page and manually setting total datasource size.

RepeaterID
- is an ID of repeater control that is being paged

EmptySpaceSize
- is a number that defines minimial size of space between numeric pagers and first/last pager

VirtualItemsCount
- manually set size of datasource when using VirtualItems PagingType (see avaliable paging types)

Samples

In provided zip file you can find source codes and also three basic samples.

ClassicPagerSample.aspx - demonstrates standard data binding (corresponds to Classic PagingType)
VirtualItemsPagerSample.aspx - demonstrates virtual items mode data binding (see VirtualItemsCount attribute)
PagersTypeSample.aspx - page that shows pagers type that RepeaterPager disposes

Conclusion

I hope there is at least one programmer that will use this component to improve quality of his project's html and will have a fun with that.

License

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