Net-informations.com
SiteMap  | About    

ASP.NET Repeater Paging

The ASP.NET Repeater is a basic container control that allows you to create custom lists from any data available to the page. The Repeater control that render HTML to display the contents of a list or data source to which they are bound. The following ASP.NET program shows how to create a custom pager to the Reapeater control.

repeater-paging

In order to build a custom pager, we need two Link button for navigating Next and Previous records and also we need a hidden field to carry the current index of the recordset. Here we are using this index value for retrieving the next group of data from recordset.

  adapter.Fill(dataset, startRecordNo, NoOfRecords, "authors")

The following ASP.NET program retrieves the data from Authors table and display 5 records per page in the Repeater control.

Default.aspx

  

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
	<form id="form1" runat="server">
	<div>
		<asp:Repeater id="repeater1" runat="server" >
		<ItemTemplate>
		<%# DataBinder.Eval(Container.DataItem, "au_id")%> &nbsp;&nbsp;
		<%# DataBinder.Eval(Container.DataItem, "au_lname")%> <br />
		</ItemTemplate>
		<SeparatorTemplate>
		<hr>
		</SeparatorTemplate>
		</asp:Repeater>
	</div>
		<input id="txtHidden" style="width: 28px" type="hidden" value="0"
		runat="server" />
		<hr>
		<asp:LinkButton ID="lnkBtnPrev" runat="server" Font-Underline="False"
		OnClick="lnkBtnPrev_Click" Font-Bold="True"><< Prev </asp:LinkButton>
		&nbsp;&nbsp;
		<asp:LinkButton ID="lnkBtnNext" runat="server" Font-Underline="False"
		OnClick="lnkBtnNext_Click" Font-Bold="True">Next >></asp:LinkButton>
	</form>
</body>
</html>


Click the following links to see full source code

C# Source Code
VB.NET Source Code
default.aspx.cs
default.aspx.vb






net-informations.com (C) 2017    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.