Problem Using Partial View In for each loop
Posted
by leen3o
on Stack Overflow
See other posts from Stack Overflow
or by leen3o
Published on 2010-05-02T11:39:01Z
Indexed on
2010/05/02
11:47 UTC
Read the original article
Hit count: 318
I'm a little confused here, I am trying use a partial view in a for each loop like so
<% foreach (var item in (IEnumerable<MVCLD.Models.Article>)ViewData["LatestWebsites"]){%>
<% Html.RenderPartial("articlelisttemaple", item); %>
<% } %>
And my partial view looks like this
<div class="listingholders">
<h4><%=Html.ActionLink(item.ArticleTitle, "details", "article", new { UrlID = item.UrlID, ArticleName = item.ArticleTitle.ToString().niceurl() }, null)%> </h4>
<p><%= Html.Encode(item.ArticleSnippet) %></p>
<div class="clearer"> </div>
</div>
But when I run the project I get told the partial view doesn't understand what item is??
CS0103: The name 'item' does not exist in the current context
I can't see why it would be doing this as I'm passing item into the partial view?
© Stack Overflow or respective owner