Programming in asp.net-mvc: MVC 4, Checkbox list and me on newest questions tagged asp.net-mvc – Stack Overflow
Morning all.
I can see this has been discussed elsewhere but was wondering if anything had change or things made simpler in MVC 4 for simpletons like me?!
Scenario
I have the following,edited, model:
public class CorporateDetails
{
public Guid? Id { get; set; }
[Key]
public int CorporateDetailId { get; set; }
public int? EmsId { get; set; }
public string EmsName { get; set; }
public virtual EmsType EmsType { get; set; }
}
public class EmsType
{
[Key]
public int? EmsId { get; set; }
public string EmsName { get; set; }
public virtual ICollection<EmsType> EmsTypes { get; set; }
}
With the following standard create view:
<fieldset>
<legend>CorporateDetails</legend>
<div class="editor-label">
@Html.LabelFor(model => model.EmsId, "EmsType")
</div>
<div class="editor-field">
@Html.DropDownList("EmsId", String.Empty)
@Html.ValidationMessageFor(model => model.EmsId)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.EmsName)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.EmsName)
@Html.ValidationMessageFor(model => model.EmsName)
</div>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
This gives me, out of the box, a beautiful drop down list a la Scott Gu’s blog
Now my real question is this – how can I effectively convert this drop down box to what will effectively be a multi select,checkbox list?
Again, apologies for going over trodden ground but I was just testing the water to see if any updates have occurred.
Please note, first MVC project so go gently, I’m feeling very thick again :’(
source: http://stackoverflow.com/questions/11204464/mvc-4-checkbox-list-and-me
Programming in asp.net-mvc: programming-in-asp-net-mvc
Recent Comments