2016-11-16 49 views
0

我在我的視圖中有以下代碼。如何在asp.net MVC5中迭代Url列表後在gridview中顯示圖像?

@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" /> 
     </div> 
     </div> 
    </div> 
} 

我以item.Posterpath的形式檢索圖像Url的字符串。

當我嘗試在item.PosterPath上添加我的Url作爲<img src=item.posterPath id="picture1" class="img-responsive"/>時,我可以看到該項目不在範圍內。 我的問題是我應該如何迭代我的模型以保持範圍並檢索我的路徑?

+0

你有沒有試過'src =「@ item.posterPath」'? –

+0

謝謝。我不知道,我怎麼看不到。如果你寫下你的評論作爲答案,我會接受它。 – codeme

回答

0

你試過src="@item.posterPath"