title: Cant closing Tag in foreach with Razor - ASP.NET MVC
body: <p>I have a <code>div</code> and each <code>div</code> has two <code>divs</code> in it like this:</p>
  
  <pre><code>&lt;div class="col"&gt;
      &lt;div class="item-c color1"&gt;..&lt;/div&gt;
      &lt;div class="item-c color2"&gt;..&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I read data from database and I want to repeat this div with a <code>foreach</code> statement.</p>
  
  <p>I use below code but I get a <code>Runtime Error</code></p>
  
  <pre><code>&lt;div class="col"&gt;
  @foreach (var item in Model)
  {
  
      &lt;div class="item-c  @("color" + index.ToString()) "&gt;..&lt;/div&gt;
      if (index % 2 == 0)
      {
          &lt;text&gt;&lt;/div&gt;&lt;div class="col"&gt;&lt;/text&gt;
      }
      index++;
      if (index &gt; 8) { index = 1; }
  }
  </code></pre>
  
  <p>my result should like this :
  <a href="https://i.stack.imgur.com/0T2n2.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0T2n2.jpg" alt="enter image description here"></a>
  I am getting this Error :</p>
  
  <blockquote>
    <p>Encountered end tag "div" with no matching start tag</p>
  </blockquote>