我有一个模型:如何在一次提交中完成多个模型的保存?
public class CustomerAttributes
{
public Int Id { get; set; }
public string value { get; set; }
}
我创建视图看起来是这样的:
<div class="editor-label">
@Html.Label("Name")
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Value)
@Html.ValidationMessageFor(model => model.Value)
</div>
<div class="editor-label">
@Html.Label("Age")
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Value)
@Html.ValidationMessageFor(model => model.Value)
</div>
<div class="editor-label">
@Html.Label("Height")
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Value)
@Html.ValidationMessageFor(model => model.Value)
</div>
所以每个文本框会在数据库中的新纪录。是否有可能做这样的事情?我该如何处理?另外我最大的问题是,每个领域可能是一个文本框或组合框或收音机....等...名称可能是一个文本框,但年龄可能是一个组合框....我知道我现在有所有的文本框,但这可能会改变。
您是否有一定数量的值希望创建或用户定义? –
它不是一个定量,它可以根据一些条件增长和缩小 – Pittfall
试试这个http://blog.stevensanderson.com/2010/01/28/editing-a-variable-length-list-aspnet-mvc- 2型/ – wes