C# Code
SqlConnection con = new SqlConnection("Data Source=VISHAL\\SQLEXPRESS;Initial Catalog=crystal_db;Persist Security Info=True;User ID=sa;Password=sa123");
con.Open();
SqlCommand cmd = new SqlCommand("Select * from demo", con);
cmd.CommandType = CommandType.Text;
SqlDataAdapter adp = new SqlDataAdapter(cmd );
DataSet dst = new DataSet();
adp.Fill(dst);
Repeater1.DataSource = dst;
Repeater1.DataBind();
.aspx code
<asp:Repeater ID="Repeater1" runat="server" >
<HeaderTemplate >
<table border ="1">
<tr>
<th>No</th>
<th>Name</th>
</tr>
</HeaderTemplate>
<ItemTemplate >
<tr>
<td>
<%#DataBinder .Eval (Container .DataItem ,"No") %>
</td>
<td>
<%#DataBinder .Eval (Container .DataItem ,"Name")%>
</td>
</ItemTemplate>
<FooterTemplate >
</table>
</FooterTemplate>
</asp:Repeater>
No comments:
Post a Comment