"[\"1454\",\"1455\",\"1456\",\"1457\",\"1458\",\"1459\"]"
I am getting a json string in my string variable in a action method that I am sending as json.stringify. These Are the id's of selected rows from jqgrid..
I just want to create an array of the Id's I am getting . I do not want the others like backslash or forward or double qutes.
Can you pl.Help me . How is this possible in C#
Controller::
public ActionResult ExportSelectedData(string SelectedRows)
{
}
View Code::
function genGraph() {
// location.href = "/WebReports/BatchReport";
var selRowIds = $("#list1").jqGrid('getGridParam', 'selarrrow');
var Array = JSON.stringify(selRowIds);
$.ajax({
type: 'POST',
url: '/WebReports/ExportSelectedData',
data: "{'SelectedRows':'" + Array + "'}",
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function (returnValue) {
location.href = "/WebReports/Download?file=" + returnValue.File;
}
});
alert(Array);
selRowIds.join()
(orselRowIds.join(",")
) to make string1454,1455,1456,1457,1458,1459
instead of["1454","1455","1456","1457","1458","1459"]
. So you can usedata: {SelectedRows: selRowIds.join()}
as parameter of Ajax. On the server side you can usestring[] selRows = SelectedRows.split(',');
to parse the data. – Oleg 20 hours agoModelBinder
or simple use object withint[]
orstring[]
as a property here alternatively. – Oleg 18 hours ago