In Asp.net MVC 3, I have my switches configured as follows:
<div class="editor-label"> @Html.LabelFor(m => m.Roles) </div> <div class="editor-field"> @Html.RadioButtonFor(model => model.Roles,false) SuperAdmin @Html.RadioButtonFor(model => model.Roles,false) Admin @Html.ValidationMessageFor(model =>model.Roles)<br/> </div>
This works fine, but for this I need to hardcode the values. Right now, I have only two values, but that can change based on the data in my db. How can I dynamically populate this list of radio objects from a database? Thanks
I have a Register ActionResult method in my controller, for example:
public ActionResult Register() {
So ViewData.Model has a list of AdminRoles. How could I access this list in my model?
source share