I am sure I am missing something very obvious, or I am not understanding what I have read so far. I have a from that contains a table of data, 2 fields of which need to be editable. The data received by the form is IEnumerable
. However, when the controller function receiving the post data, instead of it receiving an IEnumerable
, I get nothing. If I receive just the raw data type, I get the a single instance of the object with the correct id field and all other fields are empty. Could someone please point me oin the right direction?
MODEL: (Generated by EF Model first)
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
View:
@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
Controller
<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