Reputation: 13
I am trying to populate table ussing LINQ to SQL , I use the following portion of code
<h2>Index
<table class="grid">
<tr>
<th>u_name</th>
<th>u_id</th>
<th>u_sex</th>
<th>u_job_tittle</th>
<th></th>
</tr>
<% foreach (var item in Model) { %>
<tr>
<td class="left"><%item.u_name ; %></td>
<td class="left"><% item.u_id; %></td>
<td class="left"><% item.u_sex; %></td>
<td class="left"><% item.u_job_tittle ;%></td>
</tr>
<% } %>
</table>
</h2>
</asp:Content>
the problem is runtime error appear as following
Only assignment, call, increment, decrement, and new object expressions can be used as a statement
any idea to solve that
Upvotes: 0
Views: 123
Reputation: 53991
If you're trying to write the values to the page you need to use with =
or :
such that:
<td class="left"><%=item.u_name %></td>
Upvotes: 1