I'm encountering an issue where I have an array that I build up when a row is selected in my bootstrap data table. The problem arises when I try to pass this array from my view to the controller, which is supposed to fire up a partial view. Strangely, I am getting a null reference exception in my controller when I execute the code. Despite being able to see values for the array during debugging, it still shows as NULL. Any thoughts on why this might be happening?
AJAX:
function MoveSelected() {
$.ajax({
type: "Get",
url: '@Url.Action("MoveSelectedRoute", "Transport")',
data: { orders: completeArray },
success: function (data) {
$('#detail_MoveSelectedOrders').html(data);
$('#modalMoveSelectedOrders').modal('show');
}
})
}
Controller:
public ActionResult MoveSelectedRoute(string[] orders)
{
string OrdersToMove = string.Empty;
foreach (string row in orders)
{
string orderNo = orders.ToString().PadLeft(10, '0');
if (OrdersToMove == string.Empty)
{
OrdersToMove = orderNo;
}
else
OrdersToMove = OrdersToMove + "," + orderNo;
}
}