SiteMap  | About    

ASP.NET Repeater Templates

The Repeater control that render HTML to display the contents of a list or data source to which they are bound. It has no built-in layout or styles, so you must explicitly declare all layout, formatting, and style tags within the controls templates.


At a minimum, every Repeater control must define an ItemTemplate. Other optional templates can be used to customize the appearance of the list. They are ItemTemplate, AlternatingItemTemplate , SeparatorTemplate , HeaderTemplate and FooterTemplate.

ItemTemplate is required by the Repeater control and it produces one row of output for each data row. AlternatingItemTemplate is same as ItemTemplate and it renders for every other data row. HeaderTemplate and FooterTemplate render HTML immediately before and after all the data rows have been rendered and finally SeparatorTemplate render items between each data row like the HTML tags br, p, or HR.

The following ASP.NET program shows how to use Templates in Repeater Control.



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head id="Head1" runat="server">
<title>Untitled Page</title>
	<form id="form1" runat="server">
		<asp:Repeater id="repeater1" runat="server" DataSourceID="SqlDataSource1">
		<b><u>HEADER TEXT HERE</u></b><hr>
		<%# DataBinder.Eval(Container.DataItem, "stor_id")%> &nbsp;&nbsp;
		<%# DataBinder.Eval(Container.DataItem, "stor_name")%> <br />
		<hr><b><u>FOOTER TEXT HERE</u></b>
		<asp:SqlDataSource ID="SqlDataSource1" runat="server"
		ConnectionString="<%$ ConnectionStrings:SQLDbConnection %>"
		SelectCommand="select [stor_id],[stor_name] from stores" />
</html> (C) 2017    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.