aspx视图引擎 list ,遍历集合

<%@ Import Namespace="MvcFirstDemo.Models" %>--伪数据

<% List<UserInfo> list = ViewData["cc"] as List<UserInfo>;%>
<table>
<tr>
<th>用户编号</th><th>姓名</th><th>年龄</th>
</tr>


<% foreach (var dt in list)
{%>
<tr>
<td><%:dt.Id%></td>
<td><%:dt.Name %></td>
<td><%:dt.Age %></td>
</tr>

<% }%>

</table>

原文地址:https://www.cnblogs.com/cococool/p/4670481.html