MVC Rendered Partial, how to get partial/view model in main model post to controller
- by user1475788
I have a text file and when users upload the file, the controller action method parses that file using state machine and uses a generic list to store some values. I pass this back to the view in the form of an IEnumerable. Within my main view, based on this ienumerable list I render a partail view to iterate items and display labels and a textarea. Users could add their input in the text area. When the users hit the save button this ienumrable list from the partial view rendered is null. so please advice any solutions.
here is my main view
@model RunLog.Domain.Entities.RunLogEntry
@{
ViewBag.Title = "Create";
Layout = "~/Views/Shared/_Layout.cshtml";
}
@using (Html.BeginForm("Create", "RunLogEntry", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<div id="inputTestExceptions" style="display: none;">
<table class="grid" style="width: 450px; margin: 3px 3px 3px 3px;">
<thead>
<tr>
<th>
Exception String
</th>
<th>
Comment
</th>
</tr> </thead>
<tbody>
@if (Model.TestExceptions != null)
{
foreach (var p in Model.TestExceptions)
{
Html.RenderPartial("RunLogTestExceptionSummary", p);
}
}
</tbody>
</table>
</div>
}
partial view as follows:
@model RunLog.Domain.Entities.RunLogEntryTestExceptionDisplay
<tr>
<td>
@Model.TestException@
</td>
<td>@Html.TextAreaFor(Model.Comment, new { style = "width: 200px; height: 80px;" })
</td>
</tr>
Controller action
[HttpPost]
public ActionResult Create(RunLogEntry runLogEntry, String ServiceRequest, string Hour, string Minute, string AMPM,
string submit, IEnumerable<HttpPostedFileBase> file, String AssayPerformanceIssues1, IEnumerable<RunLogEntryTestExceptionDisplay> models)
{
}
The problem is test exceptions which contains exception string and comment is comming back null.