MVC4 @Html.DropDownList的用法

前台页码代码:spa

       <div style="margin:10px 5px;"><font color="red">当前角色:</font>@Html.DropDownList("RKEY", "-请选择角色-")</div>blog

 

后台数据绑定代码:io

        public ActionResult Index()
        {
            ViewBag.RKEY = new SelectList(db.Roles, "RKEY", "RoleName");
            var rolesrights = db.RolesRights.Include(r => r.Roles).Include(r => r.BaseDatas);
            return View(rolesrights.ToList());
        }
后台

效果:List

  

相关文章
相关标签/搜索