I would like to mimic the RepeatColumn function of the ASP.NET DataList control in ASP.NET MVC. The goal is to have 2 or more rows of a collection in one table row.
The following code works, but it looks very ugly to me. Is there better way to do it? Thanks for any help!
<table>
<%
for (int i = 0; i < items.Count(); i++)
{
%>
<tr>
<% for (int j = 0; j < 2; j++)
{
if (i + j < items.Count())
{
var item = items[i + j];
%>
<td>
<% Html.Encode(item.title) %>
</td>
<%
}
else
{
%>
<td> </td>
<%
}
}%>
</tr>
<%} %>
</table>