The Repeater control is a container control that allows you to create custom lists out of any data that is available to the page. In Repeater control doesn’t have built in rendering of its own so we have to provide the layout for the Repeater control. Repeater control uses following Templates,

Repeater Control Templates:

ItemTemplate: It contains HTML elements and controls to Render each data item in the datasource.

AlternatingItemTemplate: It render data same sa ItemTemplate but it’s used to create different look for alternate data rows.  

HeaderTemplate and FooterTemplate: Contains the text and controls to render at the beginning and end of the list, respectively.

SeparatorTemplate: Contains the elements to render between each item. A typical example might be a line (using an HR element).

Advantages of Repeater Control:

Personally I always try to use simplest control necessary to do the job. You'll generally find that the more features a control has, the more 'heavy' it will be. As well as increasing ViewState size, heavier controls also have a greater hit on CPU load and memory requirements.

Performance of repeater is far better than GridView. If you need basic rendering for read only items then it’s better to use Repeater Control, and if you need events, pagination and editable controls then you should go for GridView. Simpler controls with less in built functionality are speedy like Repeater Control.

Bind Repeater Control:

          It’s quite easy to bind Repeater Control. When the page runs, the Repeater control loops through the records in the data source and renders an item for each record.

HTML Code:

<html xmlns="">

<head runat="server">

    <title>Repeater control example</title>



    <form id="form1" runat="server">


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


                <table cellpadding="1" cellspacing="1" width="50%" style="font-family: Calibri;

                    border: 1px solid #C0C0C0; background-color: #D8D8D8">

                    <tr style="background-color:Gray; color:White">

                        <th>Employee-ID </th>

                        <th> Name </th>

                        <th> Designation </th>

                        <th> City </th>

                        <th> Country </th>




                <tr style="background-color: White">

                     <td> <%#DataBinder.Eval(Container, "DataItem.empid")%>  </td>

                    <td>  <%#DataBinder.Eval(Container, "")%> </td>

                    <td>  <%#DataBinder.Eval(Container, "DataItem.designation")%>  </td>

                    <td>  <%#DataBinder.Eval(Container, "")%> </td>

                    <td <%#DataBinder.Eval(Container, "")%> </td>




                <tr style="background-color:#AED6FF">

                    <td>  <%#DataBinder.Eval(Container, "DataItem.empid")%> </td>

                    <td> <%#DataBinder.Eval(Container, "")%> </td>

                    <td>  <%#DataBinder.Eval(Container, "DataItem.designation")%> </td>

                    <td <%#DataBinder.Eval(Container, "")%> </td>

                    <td>  <%#DataBinder.Eval(Container, "")%> </td>












C# code:


using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Data;

using System.Data.SqlClient;

using System.Configuration;

public partial class _Default : System.Web.UI.Page


   SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString);

    protected void Page_Load(object sender, EventArgs e)


        if (!IsPostBack)





    protected void BindData()


        DataSet ds = new DataSet();   


        string cmdstr = "Select * from EmployeeDetails";

        SqlCommand cmd = new SqlCommand(cmdstr, conn);

        SqlDataAdapter adp = new SqlDataAdapter(cmd);


        Repeater1.DataSource = ds;






cytotec abortion

abortion pill online buy abortion pills online
medical abortion pill online cytotec abortion abortion pill

View demo Download

If you enjoyed this article, get email updates (it's free).

comments powered by Disqus

Thanks for downloading..!!

Subscribe via Email
message to display in fancybox