This ASP.NET tutorial is brought to you by NetroStar, a
website development company.
In this article, I'll show you how to use Repeater in ASP.NET page.
Here is an example of Repeater:

I store the user in table "Client_NetroStar" in SQL Server. There are five fields in the table:
- ID
- Login
- FirstName
- LastName
- DateAdded
1. First Step - Insert the Repeater Control on page.
Repeater control allows you to create templates. For example you can use a template to customize the layout of the individual rows.
- HeaderTemplate - template for elements that you want to render once before your ItemTemplate section.
- ItemTemplate - template for elements that are rendered once per row of data.
- AlternatingItemTemplate - template for elements that are rendered every other row of data. This allows you to alternate background colors, for example.
- SeparatorTemplate - template for elements to render between each row, such as line breaks.
- FooterTemplate - template for elements that you want to render once after your ItemTemplate section.
Here is the part of the “ClientNetroStar.aspx” page that contains Repeater:
The Repeater has an attribute ID= "rptList". It is used in Code Behind (ClientNetroStar.aspx.cs) . Repeater uses the HeaderTemplate to insert <table> . Then it uses the ItemTemplate to display a LinkButton control that has our data in it. I'll come back to this in the next step.
The FooterTemplate is not necessary, but I put it in </table>.
2. Second Step - Get the Data to Repeater.
Here is the Page_Load event in the Code Behind file.
The first five lines open a database connection and retrieve the contents of the Client_NetroStar table. The last two lines bind our Repeater control to the DataReader.
We can use also MyGeneration to get data. Read more in Introduction to myGeneration and dOOdads.
This ASP.NET tutorial was brought to you by NetroStar, a Miami-based global
web design company.