Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Looking for repeater type functionality in ASP.Net MVC

Tags:

asp.net-mvc

I am used to using a Repeater control in conventional ASP.Net web projects. I see ASP.Net MVC doesn't have this sort of thing. What should I be using here?

EDIT:

In response to the question, what am I trying to do that I can't achieve in the foreach. I guess I am trying to get a alternating row style. Also, it just feels somewhat wrong to have stuff other than markup in the view. But maybe I will get over that as I work with it. Thanks for the answers.

like image 443
uriDium Avatar asked Dec 29 '22 23:12

uriDium


1 Answers

The simplest thing to use is a foreach loop.
What are you trying to do?

EDIT:

<%  bool odd = false;
    foreach(var row in something) { %>
    <tr class="<%= odd ? "OddRow" : "EvenRow" %>">
        ...
    </tr>
<% odd = !odd; } %>
like image 92
SLaks Avatar answered Jan 21 '23 18:01

SLaks