动态生成表格制作

   @Html.Raw("<table><tr>")
           @for (int i = 0; i < allRoles.Count; i++)
           {
               string strId = "ckb_" + allRoles[i].Id;
               if (i%3==0)
               {
                   @Html.Raw("</tr><tr>")
               }
            <td>
                <input type="checkbox" name="@strId" id="@strId" value="@allRoles[i].Id" />
                <label for="@strId">@allRoles[i].RoleName</label>
            </td>
              
           }
           @Html.Raw("</tr></table>")
原文地址:https://www.cnblogs.com/shuai7boy/p/5310402.html