Iv searched related questions, but still not able to get this to work in my situation. I am working in ASP.NET MVC.
I have a report that has 3 filters. Only 1 value can be selected for Filters 1 and 2. My 3rd filter is a Multi Select filter. I load an array with all the values selected from the Multi Select Filter, then I want to pass all 3 Filters to my controller action. Filters 1 and 2 work correctly, but my Multi Select Filter is not being passed, and shows as Null in my Actions parameter.
Below is my JavaScript and Ajax call
$('#applyFilter').click(function () {
var options = new Array();
//Fill array with values from Multi Select Filter
$('#treeFilter > option:selected').each(
function (i) {
options[i] = $(this).text();
})
var filter1 = $('#LOCFilterDropdown').val();
var filter2 = $('#ESNFilterDropdown').val();
$.ajax({
type: "GET",
url: "/Home/FilterReport",
data: {
filterOne: filter1,
filterTwo: filter2,
multiselectFilter: options
},
success: function (result) {
$('#reportTable').html(result);
}
});
});
The receiving Action
[HttpGet]
public ActionResult FilterReport(string filterOne,string filterTwo, int? page, List<string> multiselectFilter)
{
//filterOne contains correct value
//filterTwo contsins correct value
//multiSelectFilter contains null
//returns partial view
}
Can anyone tell me why my
List<string> multiselectFilter
//Iv also tried string[] multiselectFilter, but this didnt change anything
is now receiving the array from the ajax call?