It is similar to repeater Control.
It provides editing Facilities.
It provides adding new Records
It does not Provide Sorting and Paging Facilities.
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:DataList ID="DataList1" 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:DataList>
</table>
</div>
</form>
</body>
</html>
Default.aspx.cs
using System.Web.UI;
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);
DataList1.DataSource = ds;
DataList1.DataBind();
}
}
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<asp:DataList ID="DataList1" 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:DataList>
</table>
</div>
</form>
</body>
</html>
Default.aspx.cs
using System.Web.UI;
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);
DataList1.DataSource = ds;
DataList1.DataBind();
}
}
No comments:
Post a Comment
Thank you for visiting my blog