Repeater Control in ASP.Net C# Archives - Tech Insights https://reactconf.org/category/repeater-control-in-asp-net-c/ Unveiling Tomorrow's Tech Today, Where Innovation Meets Insight Sun, 18 Jan 2015 16:37:00 +0000 en-US hourly 1 https://wordpress.org/?v=6.6.2 https://i0.wp.com/reactconf.org/wp-content/uploads/2023/11/cropped-reactconf.png?fit=32%2C32&ssl=1 Repeater Control in ASP.Net C# Archives - Tech Insights https://reactconf.org/category/repeater-control-in-asp-net-c/ 32 32 230003556 Repeater Control in ASP.Net C# https://reactconf.org/repeater-control-in-aspnet-csharp/ https://reactconf.org/repeater-control-in-aspnet-csharp/#respond Sun, 18 Jan 2015 16:37:00 +0000 https://reactconf.org/repeater-control-in-aspnet-csharp/ The Repeater control is a container control which allows you to create a custom list of items to present data on the web page. The Repeater control same as a …

The post Repeater Control in ASP.Net C# appeared first on Tech Insights.

]]>
The Repeater control is a container control which allows you to create a custom list of items to present data on the web page. The Repeater control same as a gridview and datagridview. It doesn’t have built-in paging as for other control like datagridview.
Following five templates.
. HeaderTemplate :- it is used to create the Header Rows of the                         table.
. FooterTemplate :- it is used to create the Footer Rows of the                         table.
. ItemTemplate   :- it is used for formatting the items.
. AlternatingItemTemplate : alternating items formatting.
. SeparatorTemplate : it is used for separating rows and columns for                      style.
Working with Repeater Control

Open visual studio and create new website after that add a Repeater Control to a web form and then write the following code in your aspx page.
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head runat=”server”>
    <title></title>
    <style type=”text/css”>
        #form1 {
            height: 187px;
            width: 255px;
        }
    </style>
</head>
<body>
    <form id=”form1″ runat=”server”>
<h3>  Employee Details</h3>
    
  <p>
     <asp:Repeater id=”Repeater1″runat=”server”>
          <HeaderTemplate>
             <table border=1>
                <tr>
                   <td><b>Employeeid</b></td>
                   <td><b>FirstName</b></td>
                   <td><b>LastName</b></td>
                </tr>
          </HeaderTemplate>
            
          <ItemTemplate>
             <tr>
                <td> <%# DataBinder.Eval(Container.DataItem, “Employeeid”)%> </td>
                <td> <%# DataBinder.Eval(Container.DataItem, “FirstName”)%> </td>
                 <td> <%# DataBinder.Eval(Container.DataItem, “LastName”)%> </td>
             </tr>
          </ItemTemplate>
            
          <FooterTemplate>
             </table>
          </FooterTemplate>
            
       </asp:Repeater>
      
    </p>
    </form>
</body>
</html>


C# Source 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;
public partial class _Default : System.Web.UI.Page
{
    SqlConnection cnn = newSqlConnection(“Data Source=localhost;Initial Catalog=Northwind;Integrated Security=True”);
    protected voidPage_Load(object sender, EventArgs e)
    {
        string Sql = “select [EmployeeID],[FirstName],[LastName] from dbo.Employees  order by employeeid”;
        DataTable Repeaterdt = newDataTable();
        try
        {
            SqlDataAdapter SqlAda = newSqlDataAdapter(Sql, cnn);
            SqlAda.Fill(Repeaterdt);
            Repeater1.DataSource = Repeaterdt;
            Repeater1.DataBind();
        }
        catch (Exceptionex)
        {
            Response.Write(ex.Message.ToString());
        }
      
    }
}


The post Repeater Control in ASP.Net C# appeared first on Tech Insights.

]]>
https://reactconf.org/repeater-control-in-aspnet-csharp/feed/ 0 2253