1

I'm getting an out of memory exception on this loop...however, it never even reaches a second iteration. The date index is 0 when the exception is thrown.

<% int date = 0; %>
   <% while (date < Model.TimePeriod1.Count) { %>
      <tr>
         <% for (int i = 0; i < 7; i++)
            { %>
               <td><%: Model.TimePeriod1[date] %></td>
                  date = date + 1;
                  <% } %>
      </tr>
   <% } %>

1 Answer 1

5

Your date = date + 1; is html, not code; hence it never changes date, hence it fills the entire memory with the output-buffer for lots and lots and lots of Model.TimePeriod1[0]. Add a bee-sting after the %></td>:

  <tr>
     <% for (int i = 0; i < 7; i++)
        { 
           %><td><%: Model.TimePeriod1[date] %></td><%
           date = date + 1;
        } %>
  </tr>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.