I have a a ViewModel that its contains List of another ViewModel Like :
public class EditProductViewModel
{
public string Name { get; set; }
public List<ProductPriceItemViewModel> ProductList { get; set; }
}
public class ProductPriceItemViewModel
{
public int PurchasePrice { get; set; }
public int SalePrice { get; set; }
}
in View User Can Add New row and Add New Product
for do this I use a jquery like this:
$(document).on('click', '#addnewproductprice', function () {
$("#ProductPriceList tr:last").before("<tr>"+ $("#ProductPriceList tr#template").html()+"</tr>");
});
<tr id="template" class="hidden">
<td><input type="text" class="txtpurchase form-control" name="ProductList[index].PurchasePrice" /></td>
<td><input type="text" class="txtsale form-control" name="ProductList[index].SalePrice" /></td>
<span class="btnSavePrice btn btn-xs btn-info">Save</span>
</td>
</tr>
but when click submit and getting in Debig mode in Controller ,ProductList
is null
. model binder dont bind data , I dont know ?
is there a way to do this?