我不能List<album>
在这个上使用一个,只能在没有编辑标签的视图上使用,我有一个视图工作得很好,但我不能编辑它们的一个列表。
@model IEnumerable<MyMixtapezServerCodeHomePage.Models.album>
@using (Html.BeginForm("FeatureSystem", "album", FormMethod.Post))
{
<table>
<tr>
<th>
@Html.DisplayNameFor(model => model.name)
</th>
<th>
@Html.DisplayNameFor(model => model.feature)
</th>
<th>
@Html.DisplayNameFor(model => model.feature_order)
</th>
<th></th>
</tr>
@foreach (var item in @Model)
{
<tr>
<td>
<div class="editor-label">
@Html.LabelFor(model => item.name)
</div>
<div class="editor-field">
@Html.EditorFor(model => item.name,"album")
@Html.ValidationMessageFor(model => item.name)
</div>
</td>
<td>
<div class="editor-label">
@Html.LabelFor(model => item.feature,"album")
</div>
<div class="editor-field">
@Html.EditorFor(model => item.feature)
@Html.ValidationMessageFor(model => item.feature)
</div>
</td>
<td>
<div class="editor-label">
@Html.LabelFor(model => item.feature_order)
</div>
<div class="editor-field">
@Html.EditorFor(model => item.feature_order,"album")
@Html.ValidationMessageFor(model => item.feature_order)
</div>
</td>
<td></td>
</tr>
}
<input type="submit" />
</table>}
控制器
[HttpPost]
public ActionResult FeatureSystem(IEnumerable<album> albums)
{
foreach (album album in albums)
{
if (ModelState.IsValid)
{
albumRepository.Update(album);
albumRepository.SaveChanges();
}
}
return RedirectToAction("Index");
}
我收到的专辑是空的,为什么?我可以编辑一个列表吗?我只需要这个。