My controller:
IList<OrderRow> emailOrders = ParseIncomingEmails();
ret开发者_如何学JAVAurn View("ImportEmailedOrders.cshtml", emailOrders);
My aspx page allows me to iterate with: foreach (OrderRow orderRow in Model)
I've tried various combinations of '@inherits' and '@model ....' directives without finding the correct syntax to achieve the same looping mechanism for a Razor view.
thx
You should only need to put
@model IList<OrderRow>
at the top of your page.
Is the problem that you dont have the fully qualified namespace for OrderRow?
i.e.
@model IList<Namespace.OrderRow>
You can add the namespace in the web config like
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages"/>
<add namespace="MyMvcProject.Namespace"/>
</namespaces>
You want
@model IList<OrderRow>
You need to put this declaration in the beginning of the page
@model IList<OrderRow>
and you can iterate on model
@foreach(var item in model)
{
//do something
}
精彩评论