.Net MVC multiple RadioButtonFor

To render multiple RadioButtonFor in a MVC Razor view:

@{
var userRoles = new Dictionary<string, string>()
{
{“Admin”, “AdminGroup”},
{“User”, “UserGroup”}
};
}

<table>
<tr>
<td>Role</td>
<td>
@foreach (var roleOption in userRoles)
{
@Html.RadioButtonFor(x => x.UserRole, roleOption)
}
</td>
</tr>
</table>

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s