creating a row div every two items using Razor -


the following code works if each row has 2 items breaks if last row has 1 item. how work display row div every 1 or 2 items?

@{    var count = 0;    var rowcreate = false; }  if (count == 0 || (count % 2 == 0)) {     rowcreate = false;     @html.raw("<div class='row'>"); } else {      rowcreate = true; }  <div class="col-md-6">     content </div>  if (rowcreate) {    @html.raw("</div>"); }  count++; 

if (rowcreate)                 {                     @html.raw("</div>");                 }                  count++;                  if (currentpage.ancestororself(2).children.first("name == \"" + page + "\"").children.count() == count && count % 2 != 0)                 {                     @html.raw("</div>");                 } 

Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -