У меня такое ощущение, что вы, возможно, не указали ни название вашей модели, либо, возможно, MVC не нашел ваш EditorTemplate.
Обратите внимание, что расположение шаблона для этого примера: ~ / Views / Shared / EditorTemplates / FooPermissionModel.cshtml
Ниже корректно отображается шаблон EditorTemplate:
Модель:
public class FooPermissionModel
{
public string Name { get; set; }
public string Reason { get; set; }
public bool Selected { get; set; }
}
ViewModel:
public class FooManagementDetailViewModel
{
public List<FooPermissionModel> FooPermissions { get; set; }
}
Контроллер:
public ActionResult Index()
{
var fakePerms = new List<FooPermissionModel> ()
{
new FooPermissionModel { Name = "Foo1", Reason = "Boo", Selected=true },
new FooPermissionModel { Name = "Bazz", Reason = "Tootsie", Selected=false }
};
var model = new FooManagementDetailViewModel();
model.FooPermissions = fakePerms;
return View(model);
}
Вид:
@model StackExamples.Models.FooManagementDetailViewModel
<fieldset>
<legend>FooBarTitle</legend>
<div>
@Html.EditorFor(x => x.FooPermissions)
</div>
</fieldset>
EditorTemplate:
@model StackExamples.Models.FooPermissionModel
<table>
<thead>
<tr>
<th>
Heading
</th>
<th>
Heading
</th>
<th>
Heading
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
@Html.TextBoxFor(x => x.Name, new { @readonly = "readonly" })
</td>
<td>
@Html.CheckBoxFor(x => x.Selected)
</td>
<td>
@Html.TextBoxFor(x => x.Reason)
</td>
</tr>
</tbody>
</table>