I have a view using a viewmodel.
In this view, I am using a partial view inside the @using (Html.BeginForm())
block code as given below
@foreach (var party in Model.Participants)
{
Html.RenderPartial("BlankEditorRow", party);
}
Partial view has some text box fields, user can enter data in these fields. Now submit button is not placed inside partial view instead it in main view.
In my view when i click on submit button, i get null values in the viewmodel
[HttpPost]
public ActionResult ActionName(ViewModel model)
{
}
I'm not sure about how to get the post data from partial views. Can anyone please help me understand how to post data from partial view? example would be a big help
Edit: Partial View given below :
@model ASPNETMVCApplication.Models.Administration.Account.PartyModel
@using HtmlHelpers.BeginCollectionItem
<tr class="editorRow">
@using (Html.BeginCollectionItem("party"))
{
<td>@Html.TextBoxFor(m => m.FirstName, new { @style = "width: 100px;" })
</td>
<td>@Html.TextBoxFor(m => m.LastName, new { @style = "width: 100px;" })
</td>
<td>
@Html.DropDownListFor(model => model.PartyPersonalDetail.Gender, new SelectList(Model.Gender, "Id", "Name"), new { @style = "width: 100px;" })
</td>
<td>@Html.TextBoxFor(m => m.PartyPersonalDetail.MobilePhone, new { @style = "width: 100px;" })
</td>
<td>
@Html.DropDownListFor(model => model.PartyPersonalDetail.GothraId, new SelectList(Model.Gothras, "Id", "GothraName"), "--Don't Know--", new { @style = "width: 122px;" })
</td>
<td>
@Html.DropDownListFor(model => model.PartyPersonalDetail.NakshtraId, new SelectList(Model.Nakshtras, "Id", "NakshtraName"), "--Don't Know--", new { @style = "width: 122px;" })
</td>
<td>@Html.TextBoxFor(m => m.PartyPersonalDetail.EMail1, new { @style = "width: 135px;" })
</td>
<td>
<a href="#" class="deleteRow">Delete</a>
</td>
}
</tr>