I have a div and each div has two divs in it like this:

<div class="col">
    <div class="item-c color1">..</div>
    <div class="item-c color2">..</div>
</div>

I read data from database and I want to repeat this div with a foreach statement.

I use below code but I get a Runtime Error

 <div class="col">
        @foreach (var item in Model)
        {

            <div class="item-c  @("color" + index.ToString()) ">..</div>

            if (index % 2 == 2)
            {
                <text></div>        <div class="col">
        </text>
            }
            index++;
            if (index > 8) { index = 1; }

        }

I am getting this Error :

Encountered end tag "div" with no matching start tag

Related posts

Recent Viewed