problem with repeater
while i am running this code an exception is occuring at <%Eval("Firstname")%>.. the exception message is "Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control." what to do..my code is as follows
<div>This is repeater
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
<HeaderTemplate>
<table>
<tr>
<th>FirstName</th>
<th>LastName</th>
<th>City</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><% Eval("FirstName")%></td>
<td>&开发者_如何学编程lt;% Eval("LastName")%></td>
<td><% Eval("City")%></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT * FROM [Employees]">
</asp:SqlDataSource>
</div>
I think you are missing the #
symbol
try:
<%# Eval("FirstName") %>
To have the data emitted through databinding you should use the data-binding expression syntax
<%# Eval("FieldName")%>
精彩评论