Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to post data from partial view in ASP.NET MVC3?
    primarykey
    data
    text
    <p>I have a view using a viewmodel. In this view, I am using a partial view inside the <code>@using (Html.BeginForm())</code> block code as given below</p> <pre><code> @foreach (var party in Model.Participants) { Html.RenderPartial("BlankEditorRow", party); } </code></pre> <p>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.</p> <p>In my view when i click on submit button, i get null values in the viewmodel</p> <pre><code>[HttpPost] public ActionResult ActionName(ViewModel model) { } </code></pre> <p>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</p> <p>Edit: Partial View given below :</p> <pre><code>@model ASPNETMVCApplication.Models.Administration.Account.PartyModel </code></pre> <p>@using HtmlHelpers.BeginCollectionItem</p> <pre><code>&lt;tr class="editorRow"&gt; @using (Html.BeginCollectionItem("party")) { &lt;td&gt;@Html.TextBoxFor(m =&gt; m.FirstName, new { @style = "width: 100px;" }) &lt;/td&gt; &lt;td&gt;@Html.TextBoxFor(m =&gt; m.LastName, new { @style = "width: 100px;" }) &lt;/td&gt; &lt;td&gt; @Html.DropDownListFor(model =&gt; model.PartyPersonalDetail.Gender, new SelectList(Model.Gender, "Id", "Name"), new { @style = "width: 100px;" }) &lt;/td&gt; &lt;td&gt;@Html.TextBoxFor(m =&gt; m.PartyPersonalDetail.MobilePhone, new { @style = "width: 100px;" }) &lt;/td&gt; &lt;td&gt; @Html.DropDownListFor(model =&gt; model.PartyPersonalDetail.GothraId, new SelectList(Model.Gothras, "Id", "GothraName"), "--Don't Know--", new { @style = "width: 122px;" }) &lt;/td&gt; &lt;td&gt; @Html.DropDownListFor(model =&gt; model.PartyPersonalDetail.NakshtraId, new SelectList(Model.Nakshtras, "Id", "NakshtraName"), "--Don't Know--", new { @style = "width: 122px;" }) &lt;/td&gt; &lt;td&gt;@Html.TextBoxFor(m =&gt; m.PartyPersonalDetail.EMail1, new { @style = "width: 135px;" }) &lt;/td&gt; &lt;td&gt; &lt;a href="#" class="deleteRow"&gt;Delete&lt;/a&gt; &lt;/td&gt; } &lt;/tr&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload