标签:
cshtml页面代码:
@FormHelper.DropdownList(a => a.UserRoleId, model.Roles)
Models页面代码:
public List<SelectListItem> Roles { get; set; } = new List<SelectListItem>();
数据绑定
this.Roles.Add(new SelectListItem() { Text = Resources.NonUserRole, Value = "0" }); this.Roles.AddRange(SelectListItems.FromQuery(context.Set<UserRole>(), r => new { text = r.Name, value = r.Id }, r => r.text, r => r.value));
标签:
原文地址:http://www.cnblogs.com/zhongku/p/4789548.html