MVC Checkbox List
- by David in Dakota
I just wrote perhaps the ugliest bit of MVC code in existence. It is:
<table>
<tr>
<%
int i = 0;
foreach(Thyla.Models.Tag tag in this.Model)
{
i += 1;
%>
<td>
<span>
<input type="checkbox" name="TagSelector" id='<%= tag.TagName%>' value='<%= tag.TagName%>' />
<label for="<%= tag.TagName%>" title="<%= tag.TagName%>"><%= tag.TagName%></label>
</span>
</td>
<%if (i % 5 == 0){%>
</tr><tr>
<%} %>
<%} %>
<% if (i % 5 != 0){%></tr><%} %>
</table>
What is the canonical approach to making a checkbox list with a specified number of columns in ASP.NET MVC?