2

モデル内の3つのアイテムごとに連続してラップする必要があります。

現在持っている:

<% for(var i = 0; i <= Model.Count()/3; i++ ) { %>
<div class="row row-md">
    <div class="content-normal">

        <% foreach (var challenge in Model) { %>
                <div class="grid grid-col-3up">
                    <div class="mod mod-games">
                        <div class="mod-hd">
                            <h5 class="heading heading-mod heading-mod-5up heading-muted">Week 1</h5>
                        </div>
                        <div class="mod-box-banner">
                            <div class="mod-banner-box">
                                <% if (challenge.Completed) { %>
                                    <img src="assets/images/completed-banner.png" alt="" class="mod-completed-banner"/>
                                <% } %>
                            </div>
                            <div class="mod-box mod-relative ">
                                <% if (challenge.Completed) { %> 
                                    <img src="assets/images/medal-game.png" alt="" class="mod-medal-game" />
                                    <span class="mod-game-entries"><%= challenge.Entries%> Entries Earned</span>
                                    <img src="assets/images/games-burst.png" alt="" class="mod-box-img">
                                <% } else { %>
                                    <img src="<%= challenge.Image %>" alt="" class="mod-box-img" />
                                <% } %>
                            </div>
                        </div>
                        <div class="mod-hd">
                            <h4 class="heading heading-mod heading-mod-3up heading-muted"><%= challenge.ChallengeTitle%></h4>
                        </div>
                        <div class="mod-hr">
                            <hr>
                        </div>
                        <div class="mod-bd">
                            <p><%= challenge.ShortDescription%></p>
                        </div>
                        <div class="mod-btn no-pad">
                            <a href="<%= challenge.ChallengeUrl %>"class="btn">
                            Play 
                            <% if (challenge.Completed) { %>
                                    Again
                            <% } %>
                            </a>
                        </div>
                        <div class="mod-btn">
                            <a href="#" class="btn">Share</a>
                        </div>
                    </div>
                </div>  

                <% } %>  
    </div>
</div>
<% } %>

最初のforeachはOverFlowExceptionをスローします。

4

1 に答える 1

0
            <% 

                int ChallengeCt = -1;
                foreach (var challenge in Model){
                    ChallengeCt++;


                    if ((ChallengeCt) % 3 == 0)
                    {


                        %>

    <div class="row row-md">
        <div class="content-normal">


                        <%
                    }

    // Content here

    <%             
        if ( ( ChallengeCt + 1) % 3 == 0)
                {

                   %>
    </div>
</div>

                   <%
                }
     %>  

                    <% } %>  
于 2013-03-29T04:03:00.590 に答える