I am using ASP.NET MVC and bootstrap. I have many objects (> 2) in the collection, and each requires a <div class="col-xs-6"> , but with only two columns per row. How to achieve this cycle of use? There is one way, but I'm looking for something better:
@model List<Object> @using (Html.BeginForm("ActionName", "ControllerName")) { <div class="row"> @for (int i = 0; i < Model.Count; i++) { if (i % 2 != 0) { <div class="row"> <div class="col-xs-6"> @Html.TextBoxFor(o => o[i].Value) </div> </div> } else { <div class="col-xs-6"> @Html.TextBoxFor(o => o[i].Value) </div> } } </div> }
source share