1
我需要一個操作結果在我的控制器中保存來自用戶的內嵌版本。我成功地使用源自http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx的edmx創建列表,但是當我保存時我不知道如何處理actionresult。ActionResult更新數據庫在MVC4中的動態列表
見我cstml:
@model List<SCP___AgroGerente.Models.VeiculoFazendaUsuario>
@{
ViewBag.Title = "Index";
}
<div class="Cabecalho">
<div class="left">
<h2>Lista de Veículos</h2>
<h4>Aqui você cadastra as Veículos</h4>
</div>
<div class="right" style="padding-top: 28px">
@Html.ActionLink(" ", "Create", string.Empty, new { @class = "icone new" })
</div>
<div class="clear"></div>
<hr />
</div>
<table class="tabelaFormatada">
<tr>
<th>Especificação
</th>
</tr>
@using (Html.BeginForm())
{
for (int i = 0; i < Model.Count(); i++)
{
<tr>
<td>
@Html.EditorFor(m => Model[i].VeiculoEspecificacao);
</td>
</tr>
}
<p>
<input type="submit" value="Salvar Alterações" />
</p> }
</table>