mvc生成table

<table>

<%
    int count = Model.Count;
    int rowCount = count % 4 == 0 ? count / 4 : count / 4 + 1;

    for (int i = 0; i < rowCount; i++)
    {
%>
        <tr>
            <%for (int j = 0; j < 4; j++)
              { %>
              <td>
                <%
                    int index = i * 4 + j;
                    if (index < count)
                    {
                        %>
                        <%=Model[i * 4 + j]%>
                        <%
                    }
                %>
              </td>
            <%} %>
        </tr>
        <%
        } %>
</table>
原文地址:https://www.cnblogs.com/Dreaming/p/1897751.html