0

Hello I have asp mvc view page,

<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<System.Drawing.Color[,]>" %>

how I can make a loop by this model and show all elements ?

I not using Razor :(

1 Answer 1

2

You could use 2 nested loops, one for the rows and one for the columns of the matrix:

<table>
    <% for (int i = 0; i < Model.GetLength(0); i++) { %>
        <tr>
            <% for (int j = 0; j < Model.GetLength(1); j++) { %>
                <td>
                    <%= Model[i, j] %>
                </td>            
            <% } %>
        </tr>
    <% } %>
</table>
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.