我确定我遗漏了一些非常明显的东西,或者我不理解我到目前为止所读到的内容。我有一个包含数据表的 from,其中 2 个字段需要可编辑。表单接收到的数据是IEnumerable
. 但是,当控制器功能接收到发布数据时IEnumerable
,我没有收到任何信息。如果我只收到原始数据类型,我会得到具有正确 id 字段的对象的单个实例,并且所有其他字段都是空的。有人可以指出我正确的方向吗?
MODEL:(由EF Model先生成)
Partial Public Class QuoteBundlePackage_Result
Public Property id As Integer
Public Property employeeId As Nullable(Of Integer)
Public Property employeeName As String
Property bundleId As Nullable(Of Integer)
Public Property bundleDescription As String
Public Property packageId As Nullable(Of Integer)
Public Property packageContents As String
End Class
看法:
@ModelType IEnumerable(Of gbip_new.QuoteBundlePackage_Result)
@Using Html.BeginForm()
@Html.ValidationSummary(True)
<fieldset>
<legend>Quote</legend>
<table>
<tr>
<th>
@Html.DisplayNameFor(Function(model) model.employeeId)
</th>
<th>
@Html.DisplayNameFor(Function(model) model.employeeName)
</th>
<th>
@Html.DisplayNameFor(Function(model) model.bundleId)
</th>
<th>
@Html.DisplayNameFor(Function(model) model.bundleDescription)
</th>
<th>
@Html.DisplayNameFor(Function(model) model.packageId)
</th>
<th>
@Html.DisplayNameFor(Function(model) model.packageContents)
</th>
<th></th>
</tr>
@For Each item In Model
Dim currentItem = item
Html.HiddenFor(Function(modelItem) currentItem.id)
@<tr>
<td>
@Html.DisplayFor(Function(modelItem) currentItem.employeeId)
</td>
<td>
@Html.DisplayFor(Function(modelItem) currentItem.employeeName)
</td>
<td>
@Html.EditorFor(Function(modelItem) currentItem.bundleId)
</td>
<td>
@Html.DisplayFor(Function(modelItem) currentItem.bundleDescription)
</td>
<td>
@Html.EditorFor(Function(modelItem) currentItem.packageId)
</td>
<td>
@Html.DisplayFor(Function(modelItem) currentItem.packageContents)
</td>
</tr>
Next
</table>
<p>
<input id="Submit1" type="submit" value="submit" />
</p>
</fieldset>
End Using
控制器
<HttpPost()> _
Function QuoteBundlePackage(ByVal eqDetails As IEnumerable(Of Global.gbip_new.QuoteBundlePackage_Result)) As ActionResult
If ModelState.IsValid Then
'Do stuff
Return RedirectToAction("Index")
End If
Return View(eqDetails)
End Function