我新的MVC 3,并有这个问题入手,@foreach环3
我有一个类定义为
Class abc
{ public string Id { get; set; }
public string str1 { get; set; }
public string Action { get; set; }
public string Name { get; set; }
public string Title {get; set;}
}
我MVC2的aspx的ViewPage,我就是用这个ABC类为模型,并有这个代码
<%
Model.ForEach(a =>
{ %>
<%= Html.ActionLink(a.Title ,
a.Action , // <-- ActionMethod
a.Name , // <-- Controller Name.
new { key = a.Id }, // <-- Route arguments.
new { title = a.str1 })%>
<br /><br />
<% }); %>
可以请你帮我这一段代码转换为MVC Razor视图?, @model ABC
<%
Model.ForEach(a =>
{ %>
<%= Html.ActionLink(a.Title ,
a.Action , // <-- ActionMethod
a.Name , // <-- Controller Name.
new { key = a.Id }, // <-- Route arguments.
new { title = a.str1 })%>
<br /><br />
<% }); %>
当我尝试使用@foreach(模型中的var abc)时,我得到错误消息,需要实现Ienumerable?如何使用@for实现请帮助或给我指针。谢谢