Hi,
Following is a very basic example of repeater, My Table has two columns viz Val1 and Val2.
DataBinder.Eval(Container.DataItem, "Column_Name") here in the "" you will have to fill in your column name.
<form id="form1" runat="server">
<div>
<b>Using DataBinder.Eval(Container.DataItem, "col_name") method</b>
<asp:Repeater ID="Repeater1" runat="server"
DataSourceID="SqlDataSource1">
<ItemTemplate>
<table style="width: 400px; font-family: Verdana; font-size: 20px;
color: Orange;">
<tr style="background-color: #FFeFef;">
<td>
Hi, My name is
<%#DataBinder.Eval(Container.DataItem, "Val1")%>
<%#DataBinder.Eval(Container.DataItem, "Val2")%>
<%--<%# Eval("Col_Name") %> produces same result--%>
</td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ConnectionStrings:MyDatabaseConnectionString %>"
SelectCommand="SELECT * FROM [NewTable]"></asp:SqlDataSource>
</div>
</form>
0 comments:
Post a Comment