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

Last Reply one year ago By nauna

Posted one year ago


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 =>
<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.