I can't seem to figure out how to get a list of strings to render in my form as checkboxes. Tried a few things from various sites and questions/answers on here with no luck.
MODEL
var model = new ProjectModel()
{
ProjectType = new List<string>()
{
"Brand Creation",
"Web Design",
"Graphic Design",
"Custom Programming",
"E-Commerce",
"Other"
},
};
VIEW - I've tried the following ways.
@foreach (var item in Model.ProjectType)
{
@Html.CheckBoxFor(model => true, item)
<br />
}
@foreach (var item in Model.Budget)
{
@Html.CheckBox(item)
<br />
}
I would rather use Enum to display checkboxes. I know it's not your answer but you may consider doing this.
You have to do these step >
Enum
Create Html Extension method
Finally in your View
Get posted value