0
SomeControl.cshtml
@model Econo.WebUI.ViewModel.UserRoleViewModel
@Html.HiddenFor(x => Model.UserId)
@Html.EditorFor(x => Model.Roles)
/Shared/EditorTemplates/Roles.cshtml
@model Econo.WebUI.ViewModel.RoleViewModel
@Html.EditorFor(m => m.IsInRole)
@Html.EditorFor(m => m.RoleId)
@Html.EditorFor(m => m.RoleName)
由于某种原因,此输出仅为:
<input id="UserId" type="hidden" value="1LS82" name="UserId">
FalseFalse
FalseFalse显示数据库中有2个角色,用户不在其中,这是正确的。但我需要一个带有ID和名称的复选框。还能够将其提交回服务器以向用户添加角色。