In my website there is a table, in every td, there is a div with <input> inside.
I run over the table and serialize every div and post it to the server.
for (var r = 0; r < tbodyRow.length; r++) {
var tbodyCols = tbodyRow[r].cells;
for (var c = 0; c < tbodyCols.length; c++) {
row = r + 1;
cell = c + 1;
div = $("#tbody tr:nth-child(" + row + ") td:nth-child(" + cell + ") :input").serialize();
if (div != "") {
$.post("../Contoller/Action?Mode=" + Mode, div, function () { });
}
tbodyCounter++;
};
};
and in the server – the action have an object as parameter that get it.
I would like to post all the list of the object (that i have in the divs) just once
and get it as List<T> in the server side.
is it possible ?
Yes, model binding allows to do that. Refer below article
http://blog.stevensanderson.com/2010/01/28/editing-a-variable-length-list-aspnet-mvc-2-style/
Also refer below one for introduction
http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx