Skip to content

Instantly share code, notes, and snippets.

@rmariuzzo
Created February 25, 2013 13:12
Show Gist options
  • Save rmariuzzo/5029718 to your computer and use it in GitHub Desktop.
Save rmariuzzo/5029718 to your computer and use it in GitHub Desktop.
Create columns using Twitter Bootstrap in Razor with C#.
for (var i = 0; i < list.Count; i++)
{
var first = i == 0;
var last = i == list.Count - 1;
var current = i + 1;
var previous = i;
if (first || previous % 3 == 0)
{
@Html.Raw("<div class=\"row\">");
}
<div class="span4">
Column @current
</div>
if (last || current % 3 == 0)
{
@Html.Raw("</div>");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment