Ola.. 我在编辑表格中的几个模型时遇到问题。我在页面上有一个模型列表(带有foreach),例如
<table id="grid-table" >
@foreach (var image in ViewBag.Images)
{
<tr>
<td >
<a href="@Url.Action("ShowFullImage", new { id = @image.ID })" rel="lightbox[roadtrip]" title="@image.Description" >
<img src="@Url.Action("ShowImageThumbneil", new { id = @image.ID })" alt="@image.AlternateText" />
</a>
</td>
<td >
@using (Html.BeginForm("SaveImageInfo", "Admin", FormMethod.Post))
{
@Html.TextAreaFor(m => m.Description) <br />
@Html.TextBoxFor(m => m.AlternateText) <br />
@Html.LabelFor(m => m.ID)
<div id="item-post" >
<input title="Подтвердить" type="submit" value="Подтвердить" />
</div>
}
</td>
</tr>
}
我想有一种方法来编辑一个模型项目。在控制器中,我有这样的东西:
[HttpPost]
public ActionResult SaveImageInfo(ImageModel imageModel)
{
Image img = _core.GetImageByID(_client, imageModel.ID);
img.AlternateText = imageModel.AlternateText;
img.Description = imageModel.Description;
_core.SaveImageInfo(_client, img);
return View();
}
但是,当然,它不起作用..有人可以帮助我吗?