Brisresacenue
New Member
I have searched a lot and spend 3 days only for searching and trying different technique (on stackoverflow etc) but I find no solution for implementing checkboxlist in asp.net mvc. And at last I am posting my problem to stackoverflow;
So, my model looks like this;
Many to Many relationship of my model(1 category may contain many projects and a project may belongs to many categories)
My controller;\[code\] [HttpGet] [Authorize(Roles = "Admin")] public ActionResult ProjectAdd() { return View(); }\[/code\]My view;\[code\]@using (Html.BeginForm()){ @Html.ValidationSummary(true) <fieldset> <legend>Add New Project</legend> <div class="editor-label"> @Html.LabelFor(model => model.ProjectHeading) </div> <div class="editor-field"> @Html.EditorFor(model => model.ProjectHeading) @Html.ValidationMessageFor(model => model.ProjectHeading) </div> <div class="editor-label"> @Html.LabelFor(model => model.ProjecctUrl) </div> <div class="editor-field"> @Html.EditorFor(model => model.ProjecctUrl) @Html.ValidationMessageFor(model => model.ProjecctUrl) </div> <div class="editor-label"> @Html.LabelFor(model => model.ProjectLongDescription) </div> <div class="editor-field"> @Html.EditorFor(model => model.ProjectLongDescription) @Html.ValidationMessageFor(model => model.ProjectLongDescription) </div> <div class="editor-label"> @Html.LabelFor(model => model.PromoFront) </div> @Html.EditorFor(model => model.PromoFront) @Html.ValidationMessageFor(model => model.PromoFront) <div class="editor-label"> @Html.LabelFor(model => model.ProjectThubmnail) </div> <div class="editor-field"> @Html.EditorFor(model => model.ProjectThubmnail) @Html.ValidationMessageFor(model => model.ProjectThubmnail) </div> <div class="editor-label"> @Html.LabelFor(model => model.ProjectImage) </div> <div class="editor-field"> @Html.EditorFor(model => model.ProjectImage) @Html.ValidationMessageFor(model => model.ProjectImage) </div> <div class="editor-label"> @Html.LabelFor(model => model.CategoryId) </div> <div class="editor-field"> @Html.EditorFor(model => model.CategoryId) @Html.ValidationMessageFor(model => model.CategoryId) </div> <p> <input type="submit" value="http://stackoverflow.com/questions/12650441/Create" class="submit" /> </p>\[/code\]So, my question is How do I display checkboxlist for categories in my view?
How do I get selected values from that checkboxlist?
So, my model looks like this;

My controller;\[code\] [HttpGet] [Authorize(Roles = "Admin")] public ActionResult ProjectAdd() { return View(); }\[/code\]My view;\[code\]@using (Html.BeginForm()){ @Html.ValidationSummary(true) <fieldset> <legend>Add New Project</legend> <div class="editor-label"> @Html.LabelFor(model => model.ProjectHeading) </div> <div class="editor-field"> @Html.EditorFor(model => model.ProjectHeading) @Html.ValidationMessageFor(model => model.ProjectHeading) </div> <div class="editor-label"> @Html.LabelFor(model => model.ProjecctUrl) </div> <div class="editor-field"> @Html.EditorFor(model => model.ProjecctUrl) @Html.ValidationMessageFor(model => model.ProjecctUrl) </div> <div class="editor-label"> @Html.LabelFor(model => model.ProjectLongDescription) </div> <div class="editor-field"> @Html.EditorFor(model => model.ProjectLongDescription) @Html.ValidationMessageFor(model => model.ProjectLongDescription) </div> <div class="editor-label"> @Html.LabelFor(model => model.PromoFront) </div> @Html.EditorFor(model => model.PromoFront) @Html.ValidationMessageFor(model => model.PromoFront) <div class="editor-label"> @Html.LabelFor(model => model.ProjectThubmnail) </div> <div class="editor-field"> @Html.EditorFor(model => model.ProjectThubmnail) @Html.ValidationMessageFor(model => model.ProjectThubmnail) </div> <div class="editor-label"> @Html.LabelFor(model => model.ProjectImage) </div> <div class="editor-field"> @Html.EditorFor(model => model.ProjectImage) @Html.ValidationMessageFor(model => model.ProjectImage) </div> <div class="editor-label"> @Html.LabelFor(model => model.CategoryId) </div> <div class="editor-field"> @Html.EditorFor(model => model.CategoryId) @Html.ValidationMessageFor(model => model.CategoryId) </div> <p> <input type="submit" value="http://stackoverflow.com/questions/12650441/Create" class="submit" /> </p>\[/code\]So, my question is How do I display checkboxlist for categories in my view?
How do I get selected values from that checkboxlist?