There is no helper to do this for you. But it is not so difficult. Assuming you already have a select list in the ViewBag, this will work just fine.
@foreach (var o in ViewBag.Options) { <label><input type="checkbox" name="MyOptions" value="@o.Value"/> <span>@o.Text</span></label> <br/> }
You see a model that should be able to accept an array, for example ...
public class MyViewModel { public ICollection<string> MyOptions { get; set; } }
The selected values ββwill be in MyOptions .
Jarrett Meyer Mar 12 '11 at 20:26 2011-03-12 20:26
source share