Skip to content

Instantly share code, notes, and snippets.

@hanssens
Created October 28, 2011 11:10
Show Gist options
  • Save hanssens/1322078 to your computer and use it in GitHub Desktop.
Save hanssens/1322078 to your computer and use it in GitHub Desktop.
[MVC3/RAZOR] MultiColumnRepeaterExtension
public static void MultiColumnRepeater<T>(this HtmlHelper helper, IEnumerable<T> model, int columnCount, Action rowHeader, Action<T> itemTemplate, Action rowFooter)
{
int currentColumn = 0;
foreach (T item in model)
{
if (currentColumn == 0)
rowHeader();
itemTemplate(item);
++currentColumn;
if (currentColumn >= columnCount)
{
rowFooter();
currentColumn = 0;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment