Get selected (checked) CheckBox values as Comma Separated String in Controller in ASP.Net MVC

Last Reply 4 months ago By nauna

Posted 4 months ago

hello,

i have this checkbox list bind with list working fine

on button submit even i want to get all the selected checkboxlist value as comma seperated in my string on my controller 

@model IEnumerable<MVCApp.Models.FirstCategories>
@using (@Html.BeginForm("CheckboxListTopcategoryMenu_post", "Application", FormMethod.Get))
{  
foreach (var item in Model)
{
    @Html.CheckBoxFor(m => item.isSelected)
    @Html.DisplayFor(m => item.Title)
    @Html.HiddenFor(m => item.id)
}
<input id="Button2" type="submit" class="btn red" value="Search" />
}
        public ActionResult CheckboxListTopcategoryMenu_post(List<FirstCategories> categoryselected)
        {
            string _searches = "";
            foreach (FirstCategories cat in categoryselected)
            {
                _searches = cat.isSelected.ToString();
            }
            return View();
        }

but it gives error pls advice

This question does not have replies that have been liked.