codeme codeme - 1 year ago 55
ASP.NET (C#) Question

How to show images in a gridview after iterating over a list of Url's in MVC5?

I have the following code in my View.

@model MovieApp.Models.HomeIndexViewModel
@foreach (var item in Model.Movies)
<div class="container">
<div class="row">
<div class="col-xs-4">
<img src=item.posterPath id="picture1" class="img-responsive" />

I retrieve the image Url's on item.Posterpath as a string.

When I try to add my Url's on item.PosterPath as
<img src=item.posterPath id="picture1" class="img-responsive"/>
I can see that the item is not in scope.
My question is how i should iterate over my Model to stay in the scope and retrieve my paths?

Answer Source

have you tried src="@item.posterPath" ?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download