MVC 3 - Editor template for List<> Model [closed]

廉价感情. 提交于 2019-12-13 16:02:48

问题


I am building my first Razor app and really loving it. I am trying to get the low-down on how to create an editor template that renders out an editable list of items without a foreach loop. Is this possible?

Here are the basics of what I am trying to achieve:

In my view (Views/Image/Homepage.cshtml) I have:

@model List<MyNameSpace.Image>

@{
    ViewBag.Title = "Homepage Images";
}

@*????*@
@Html.EditorFor(Model => Model)

And in my editor template (Views/Image/EditorTemplates/Image.cshtml??) I have:

@model MyNameSpace.Image

<div>@Html.TextBoxFor(Model => Model.Title)</div>
<div>@Html.TextBoxFor(Model => Model.LongDescription)</div>

回答1:


LOL this is embarrassing but worthy of mentioning, the code above works fine, I created a test list in the controller but forgot to pass it to the view :-D



来源:https://stackoverflow.com/questions/6880328/mvc-3-editor-template-for-list-model

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!