Asp.Net MVC4 Display CheckboxList
Przeszukałem dużo i spędziłem 3 dni tylko na poszukiwaniu i wypróbowywaniu różnych technik (na stackoverflow itp.), Ale nie znalazłem rozwiązania do implementacji listy kontrolnej w asp.net mvc. I w końcu wysyłam mój problem do stackoverflow;
Mój model wygląda tak;
Związek wielu z moimi modelami (1 kategoria może zawierać wiele projektów, a projekt może należeć do wielu kategorii)
Mój kontroler;
[HttpGet]
[Authorize(Roles = "Admin")]
public ActionResult ProjectAdd()
{
return View();
}
Mój widok;
@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="Create" class="submit" />
</p>
Więc moje pytanie brzmiJak wyświetlić listę wyboru dla moich kategorii?
Jak uzyskać wybrane wartości z tej listy wyboru?