Html.EditorFor不在EditorTemplates中呈现视图

时间:2014-04-17 13:55:58

标签: asp.net asp.net-mvc

我有查看模型:

public class OrderInfoViewModel
    {
        public Order Order { get; set; }

        public IList<OrderDetail> OrderDetails { get; set; }
    }

在视图/Home/Index.cshtml中我有:

@model MyApp.ViewModels.OrderInfoViewModel
@{
    ViewBag.Title = "Home Page";
}

@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)

    @Html.EditorFor(x => x.Order)

    @Html.EditorFor(x => x.OrderDetails)

    <input type="submit" value="Save" />    
}

在view / Home / EditorTemplates / OrderDetail中我有:

@model MyApp.Model.OrderDetail

@{
    Layout = null;
}

test

在/ Home / EditorTemplates / OrderDetail中查看不呈现:(但如果我在视图模型类 IList OrderDetails 中删除IList到 OrderDetail OrderDetails 那么它可以工作,为什么?:(

0 个答案:

没有答案