Blog
    C#
    ADO.Net
    .NET
    ASP.Net & Web Forms
    Custom Controls
    Web Development
    Exception Handling
    XML
    Database
    Security in .Net
    Testing
    Web Services
    Windows Services
    Windows Controls
    WCF
    AJAX
    WPF
    XAML
    Reporting
    Setup
    VB.Net
    LINQ
    JQuery
    SilverLight
    JavaScript
    HTML5
    Crystal Report
    Cloud Computing
    Share Point
    Visual C++
    MVC
    Android
    PHP
    Java
    HTML
    WordPress
    Joomla
    Products
    Drupal
    Windows Phone
    JSON
    LightSwitch
    iPhone/iPad
    Ruby on Rails
    IIS 7
    Windows 8
    CSS/CSS3
    Excel
    MS Access
    Shortcut Keys
    Visual SourceSafe
    Team Foundation Server
    APIs
Follow Us
Follow _MindStick_ on Twitter View MindStick Software's LinkedIn profile View MindStick Software's Facebook profile
Top Contributor
Advertisement
Advertise with Us
Mindstick
Article Article  Forum Forum  Blog Blog  Quiz Quiz  Beginner Beginner  Careers Careers  Contact Contact  Login Login  
Home | Product | Services | About Us | Interview | DeveloperSection | Submit an Article | Submit Blog
Report Abuse Form
Reason:    
 

Home >> ASP.Net & Web Forms >> ASP.Net Repeater Control
ASP.Net Repeater Control

What is ASP.Net Repeater Control ? and how can use it in our asp.net program?
Views: 5725     Comments: 0
by Arun Singh on 7/4/2011

Repeater Control :

 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, an XML file, or another list of items. Repeater control is an iterative control in the sense it loops each record in the DataSource and renders the specified template (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 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>

Title :  
Comment :
Text ColorBackground Color
BoldItalicUnderline
LeftCenterRightJustify
Ordered ListBulleted List
IndentOutdent
Horizontal Rule
SubscriptSuperscript
HyperlinkImage
Design ModeDesign
View HtmlHtml
       
 
Report Abuse Form
Reason:    
 
Latest ArticleRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Latest Blogs by Arun SinghRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Top Viewed ArticlesRSS Feed
    
    
    
    
    
    
    
    
    
    
Top Viewed BlogsRSS Feed
    
    
    
    
    
    
    
    
    
    
Latest Interview QuestionsRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Total Online Users: 6095
  
Copyright © 2013MindStick. All Rights Reserved.