Repeater Control
This Control is used to display the data in plain Text.
Repeater Control does not provide designing Facilities, Editing Facilities, Sorting Facilities
It is faster as compared to GridView, DataList
Default.aspx
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<asp:Repeater ID="Repeater1" runat="server">
<HeaderTemplate>
<tr>
<th>
EmpNo
</th>
<th>
EmpName
</th>
<th>
Designation
</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td> <%#DataBinder.Eval(Container.DataItem,"eno")%></td>
<td> <%#DataBinder.Eval(Container.DataItem,"ename")%></td>
<td><%#DataBinder.Eval(Container.DataItem,"designation")%></td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
</div>
</form>
</body>
</html>
Default.aspx.cs
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class RepeaterControl : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("user id=sa;password=uday;database=uday;data source=localhost");
SqlCommand cmd = new SqlCommand("select *from employee", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
Repeater1.DataSource = ds;
Repeater1.DataBind();
}
}
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<asp:Repeater ID="Repeater1" runat="server">
<HeaderTemplate>
<tr>
<th>
EmpNo
</th>
<th>
EmpName
</th>
<th>
Designation
</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td> <%#DataBinder.Eval(Container.DataItem,"eno")%></td>
<td> <%#DataBinder.Eval(Container.DataItem,"ename")%></td>
<td><%#DataBinder.Eval(Container.DataItem,"designation")%></td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
</div>
</form>
</body>
</html>
Default.aspx.cs
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class RepeaterControl : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("user id=sa;password=uday;database=uday;data source=localhost");
SqlCommand cmd = new SqlCommand("select *from employee", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
Repeater1.DataSource = ds;
Repeater1.DataBind();
}
}
No comments:
Post a Comment
Thank you for visiting my blog