在我的 MVC3 项目中,我有一个这样的模型
Public Class Description
Public Property DescriptionId As Integer
<DisplayName("Product Title"), Required(ErrorMessage:="A Product Title is required"), StringLength(160)>
Public Property ProductTitle As String
<DisplayName("Product Description"), DataType(DataType.MultilineText)>
Public Property ProductDescription As String
End Class
从如下视图
@ModelType MyProject.Description
@Code
ViewData("Title") = "Create"
End Code
<h2>Create</h2>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@Using Html.BeginForm()
@Html.ValidationSummary(True)
@<fieldset>
<legend>Description</legend>
<div class="editor-label">
@Html.LabelFor(Function(model) model.ProductTitle)
</div>
<div class="editor-field">
@Html.EditorFor(Function(model) model.ProductTitle)
@Html.ValidationMessageFor(Function(model) model.ProductTitle)
</div>
<div class="editor-label">
@Html.LabelFor(Function(model) model.ProductDescription)
</div>
<div class="editor-field">
@Html.EditorFor(Function(model) model.ProductDescription)
@Html.ValidationMessageFor(Function(model) model.ProductDescription)
</div>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
End Using
<div>
@Html.ActionLink("Back to List", "Index")
</div>
我可以一次创建一个新的描述,但是有没有一种方法可以一次插入更多的描述(例如五个描述)以及如何在控制器操作中获取它们?