July 22, 2010

Custom pagination with Repeater Control

Binding a repeater control is a simple task but to do pagination on a repeater control or custom pagination on any data control is a little bit tough. This article demonstrates how to do custom pagination for any data control, or pagination with a repeater control and also how to bind a repeater control.

ASP.NET 2.0 provides five types of data controls among which the Repeater control is the fast bound data control. Nevertheless, there is no built-in pagination with this control. This means, binding numbers of records without pagination is not a good programing concept, since it will display entire data on a single page and the size of the page will become too long. So the solution is, custom pagination, if no in-built pagination is provided.

>>Read complete article & download sample code

Repeater within Gridview in C# ASP.NET 2.0

Inserting a repeater within gridview is an easy task, but binding the headline in gridview and having data items correspond to the particular headline into a repeater, is a little bit tricky. Following a requirement I was given, I had to bind company name as a headline and the top four news of the company as data items under the headline. Then the next company name, and the top four news of that respective company and so on.

In this article, I have used a repeater control to bind news while I am binding company name in gridview. We can also make the company name as a link button which, on clicking, will navigate to the corresponding page. For this we have to pass navigate the URL for a company dynamically. We can do this by writing code in the OnRowDataBound event of gridview. We can also make the news row as link.

>>Read complete article & download sample code