---
title: "ASP.Net Repeater Control"  
description: "The Repeater control is used to display a repeated list of items that are bound to the control. The Repeater control may be bound to a database table"  
author: "Anonymous User"  
published: 2011-07-04  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/197/asp-dot-net-repeater-control  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 2 minutes  

---

# ASP.Net Repeater Control

The [Repeater](https://www.mindstick.com/forum/136/how-to-find-control-inside-of-repeater) [control](https://www.mindstick.com/blog/154/how-to-find-parent-of-control-in-wpf) is used to display a repeated list of [items](https://www.mindstick.com/articles/44359/store-your-valuable-items-in-a-mini-storage-unit) that are bound to the control. The Repeater control may be bound to a [database table](https://www.mindstick.com/forum/159366/how-to-test-regular-expressions-in-sql-without-using-database-table), an [XML file](https://www.mindstick.com/articles/75/how-to-read-and-write-xml-file-through-c-sharp), or another list of items. Repeater control is an iterative control in the sense it loops each record in the [DataSource](https://www.mindstick.com/blog/447/listing-the-databases-connected-to-the-datasource) and renders the specified [template](https://www.mindstick.com/blog/282/creating-custom-template-in-joomla) ([ItemTemplate](https://www.mindstick.com/forum/2057/access-textbox-in-itemtemplate)) for each record in the DataSource collection.\

To use Repeater Control drag it form ToolBox left pane into your .aspx file or write the following [ASP.Net](https://www.mindstick.com/articles/934/default-folders-available-inside-the-asp-dot-net-application-folder) Repeater Control in your .aspx file.

```
<asp:Repeater ID="Repeater1" runat="server"></asp:Repeater>
```

##### Example: Here we are making a List to add dynamically main category

##### item and their sub category item with help of Repeater Control.

###

```
<body>    <form id="form1" runat="server">    <div style="height: 462px; width: 906px;">           <%-- // table to take  maincategory item  --%>            <table id ="main_Category"                 style="position:absolute; top: 51px; left: 46px; height: 50px; width: 540px;" border="1px">               <tr style="background-color:DarkOrange">                      <td class="style1">                                                <asp:Label ID="Label1" runat="server" ForeColor="White"                               Text="Enter Main Category Name ::    " BackColor="DarkOrange"></asp:Label>                                            </td>                      <td class="style1">                                                <asp:TextBox ID="TextBox1" runat="server" Width="213px " AutoComplete ="off"                           ></asp:TextBox>                                            &nbsp;&nbsp;&nbsp;                           <asp:Button ID="Button1" runat="server" Text="Add" onclick="Button1_Click" />                                            </td>               </tr>                            </table>            <br />            <br />            <br />            <br />            <br />            <br />            <br />            &nbsp;&nbsp;&nbsp;           <%--  //Asp.Net Repeater Control to add Main Category Item--%>            <asp:Repeater ID="MainRepeater" runat="server"                 onitemcommand="MainRepeater_ItemCommand" onitemdatabound="MainRepeater_ItemDataBound"                  >                <HeaderTemplate><ul>                     <asp:Label ID="Label4"  runat="server" Text="Articles" BackColor="DarkOrange" ForeColor="White" Width="50%" BorderWidth="1px" ></asp:Label>                    <br></br>                </HeaderTemplate>                         <FooterTemplate></ul></FooterTemplate>            <ItemTemplate>                <table border="1px" width="50%" style=" border-bottom-width:1px; border-bottom-color:Purple">                                    <tr style="background-color:DarkOrange">                     <td style="border-bottom-width:1px">                     <%--//Bind main Category table item with main Repeater control --%>                          <asp:Label ID="Label2" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"CategoryName") %>' Width="145px" BackColor="DarkOrange" ForeColor="White">></asp:Label>                          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                          <asp:TextBox ID="TextBox2" runat="server" ></asp:TextBox>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                          <asp:Button ID="Button2" runat="server" Text="Add"   />                                                                       </td>                   </tr>                  </table>                 <%--  //Child Repeater Control in ASP.Net to repeat subcategory item list  --%>                   <asp:Repeater ID="ChildRepeater" runat="server">                         <HeaderTemplate><ul></HeaderTemplate>                         <FooterTemplate></ul></FooterTemplate>                         <ItemTemplate>                           <li>                           <%-- // Bind subcategory  table item  with  child repeater control--%>                               <asp:Label ID="Label3" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"SubCategoryName") %>'>></asp:Label></li>                                                         </ItemTemplate>                         </asp:Repeater>                </ItemTemplate>                  </asp:Repeater>    </div>    </form></body>
```

---

Original Source: https://www.mindstick.com/blog/197/asp-dot-net-repeater-control

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
