i have a problem sending a multidimensional array to my controller. I have a table with 30 rows, this rows are created in a for loop.
The thing is i create a multidimensional array for the 5 elements inside of one row of my table.
function
$.fn.RealizarCalculo = function (count) {
var admin = $("#AdminSimple" + count).val();
var fondo = $("#FondosSimple" + count + " option:selected").text();
var secId = $("#FondosSimple" + count).val();
var monto = $("#MontoSimple" + count).val();
var porcentaje = $("#PorSimple" + count).val();
var list = new Array();
if (admin != "" && secId != "" && monto != "" && porcentaje != "")
{
for (var i = 1; i <= 30; i++)
{
var admin = $("#AdminSimple" + i).val();
var fondo = $("#FondosSimple" + i + " option:selected").text();
var secId = $("#FondosSimple" + i).val();
var monto = $("#MontoSimple" + i).val();
var porcentaje = $("#PorSimple" + i).val();
list[i] = [{ administrador: admin, fondoCartera: fondo, sec: secId, montoCartera: monto, porcentajeC: porcentaje}];
}
$.ajax({
url: "Simu/RealizarSimulacion",
type: "POST",
traditional: true,
contentType: 'application/json',
data: JSON.stringify({ lista:list }),
dataType: 'json'
}).done(function () {
alert("sucess");
});
}
};
How i receive this array i created?
i have tried but is not working, is just receive a list of objects.
Controller
public ActionResult RealizarSimulacion(Array lista)
{
return View("Simulador");
}
Thanks for help, and sorry for my English, i'm chilean.
objecthas no such properties. I've not actually done this myself (POSTing json like this), so I'm not sure exactly what the correct things would be to use, but I wonder if alist<dynamic>would work, or maybe there's another data structure..list.push({ administrador: admin, fondoCartera: fondo, sec: secId, montoCartera: monto, porcentajeC: porcentaje});.