strongly typed MVC View for dynamically added rows from jquery

302 views Asked by At

I have a model as follows:

    public class Order   {public Customer Customer{get;set};   public List<Customer> CustomerList {get;set};}

I have a strongly typed html row as follows:

<table>
   <tr>
        <td>@Html.TextBoxFor(model => model.Customer.CustomerName)</td>
        <td>@Html.TextBoxFor(model => model.Customer.CustomerEmail)</td>
        <td>@Html.TextBoxFor(model => model.Customer.CustomerAddress)</td>
    </tr>
</table>"

A new row is dynamically added when a "Add New Row" label is clicked via jQuery.

Now when I submit the form I get only the first row in the controller object in the "Customer" property (thats apt). How can I get all rows in the form of a CustomerList.

referring to http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx/ got me a bit closer but,doesn't serve the purpose completely.

Is there a way I can achieve that?

Thanks for any help.

0

There are 0 answers