Hi All
I'm wondering if someone can direct me to the best possible way to post data from a repeated form to a controller action. In my project i have the following:
Public Class TicketHoder
{
public string Name {get:set;}
public string Mobile {get;set;}
}
[HttpPost]
public ActionResult SaveDetails(TicketHolder model)
{
return View(model)
}
@using(Html.BeginForm("SaveDetails", "MyController", FormMethod.Post, new {id = "saveForm"}))
{
for (int i = 0; i < ViewBag.Quantity; i++)
{
<div>
<label for="TicketHolder.Name" class="left">Ticket Holder Name<span
class="required">*</span></label>
</div>
<div>
@Html.TextBoxFor(m => m.TicketHolder.Name, new { maxlength = 25, tabindex = 1 })
</div>
<div>
<label for="TicketHolder.Mobile" class="left">Ticket Holder NU,ber<span
class="required">*</span></label>
</div>
<div>
@Html.TextBoxFor(m => m.TicketHolder.Mobile, new { maxlength = 25, tabindex = 2 })
</div>
}
}
How can i go about in achieving this? or is there a better way i go about in achieving this?
Thank you
What I have tried:
Currently when i post the data , the only information that is sent to the controller is for the first form and that it. so i'm stuck and not sure on how i can go about in achieving this.