The model is not overly complex. It has a list of items each of which is generated in its own form with its own submit button. Each submit button has its onw id. The first form returns what I need. When I view the results from the form, if I have selected the first record, I get a single item in eqDetails containing the information from the form. Any other item sends back nothing. I have tried miving the submit buttom to the template and returning the detail model, but that did not return anything. Examining the page source shows that each form's submit button does have a unique id. If none brought back data I am sure I would be less confused. Any ideas and thoughts are welcome. I will need a separate form for each employee, as I will eventually need to set only one to edit at a time.
Thanks
Controller
Function EditEmployeeCoverage(Optional ByVal id As Integer = Nothing) As ActionResult
'id is quote.id
Dim viewModel As New EmployeeCoverageViewModel(id)
Return View(viewModel)
End Function
<HttpPost()> _
Function EditEmployeeCoverage(ByVal viewModel As EmployeeCoverageViewModel) As ActionResult
Return RedirectToAction("EditEmployeeCoverage", New With {.id = viewModel.quote.id})
End Function
ViewModel
Public Class EmployeeCoverageViewModel
Public Property productTypes As List(Of ProductType)
Public Property qtEmployees As List(Of EmployeeQuote)
Public Property eqDetails As New List(Of EmployeeCoverageDetailRecord)
Public Property qtBlended As String
End Class
Public Class EmployeeCoverageDetailRecord
Public Property empId As Integer
Public Property empName As String
Public Property empMonIncome As Integer
Public Property quoteId As Integer
End Class
**View - **
@ModelType gbip_new.EmployeeCoverageViewModel
@Code
ViewData("Title") = "EditEmployeeCoverage"
End Code
<h2>Edit Employee Coverage - @Model.firm.name</h2>
Note that caps can be adjusted down, but can not be adjusted above the limit set by an ewployees monthly income
<br />
Edit @Model.qtBlended Coverage
<h3>Effective Date: @Html.DisplayFor(Function(model) model.quote.effectiveDate)</h3>
<hr />
@For count = 0 To Model.eqDetails.ToList.Count - 1
Dim i = count
@Using Html.BeginForm("EditEmployeeCoverage", "EmployeeQuote", FormMethod.Post)
@<fieldset>
<legend>EmployeeCoverageViewModel</legend>
<input id="@("Submit" + i.ToString)" type="submit" value="@("Submit" + i.ToString)" />
@Html.EditorFor(Function(Model) Model.eqDetails(i))
</fieldset>
End Using
Next
Editor Template for Detail View
@ModelType gbip_new.EmployeeCoverageDetailRecord
@Html.HiddenFor(Function(model) model.empId)
@Html.HiddenFor(Function(model) model.quoteId)
@Html.EditorFor(Function(model) model.empName)