MVC4 @Html.DropDownList的用法

前台页码代码:

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

 

后台数据绑定代码:

        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());
        }

效果:

  

 

posted @ 2017-03-23 10:21  Resources  阅读(2679)  评论(0编辑  收藏  举报