Repeat div with foreach?

Asked

Viewed 259 times

0

I have a list of registered users displays the most important data such as name and email. I created a div to display this data. However, I do not want to display everything in the same div, I would like to create a way to repeat this div according to the number of registered users. It is possible to do this?

  • You are using Razor to generate the views?

1 answer

1


If you are using Razor to generate your views, you can place the creation of the Divs inside the foreach.

@forach(var usuario in ViewBag.usuarios){
    <div>
        @usuario.nome - @usuario.email
    </div>
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.