title: MVC If statement in View
body: <p>I have problem with IF statement inside MVC View. I am trying to use it for creating row for every three items.</p>
  
  <pre><code>&lt;div class="content"&gt;
    &lt;div class="container"&gt;
      @if (ViewBag.Articles != null)
      {
        int nmb = 0;
        foreach (var item in ViewBag.Articles)
        {
          if (nmb % 3 == 0) { 
            &lt;div class="row"&gt;  
          }    
          &lt;a href="@Url.Action("Article", "Programming", new { id = item.id })"&gt;    
            &lt;div class="tasks"&gt;    
              &lt;div class="col-md-4"&gt;    
                &lt;div class="task important"&gt;
                  &lt;h4&gt;@item.Title&lt;/h4&gt;
                  &lt;div class="tmeta"&gt;
                    &lt;i class="icon-calendar"&gt;&lt;/i&gt; @item.DateAdded - Pregleda:@item.Click  
                    &lt;i class="icon-pushpin"&gt;&lt;/i&gt; Authorrr  
                  &lt;/div&gt;    
                &lt;/div&gt;    
              &lt;/div&gt;
            &lt;/div&gt;
          &lt;/a&gt;
          if (nmb % 3 == 0) { 
            &lt;/div&gt;
          }
        }
      }
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>