码迷,mamicode.com
首页 > Web开发 > 详细

asp.net mvc SelectList使用

时间:2015-11-25 19:21:01      阅读:510      评论:0      收藏:0      [点我收藏+]

标签:

action代码:

BusinessPublicContent pc = db.BusinessPublicContent.Where(m => m.BusinessPublicContentID == id).FirstOrDefault();
            ViewBag.data = pc;

            var query = from m in db.BusinessMenu
                        where m.Status == 1 && m.IsDelete == 0 && m.ParentBusinessMenuID == 0

                        select new
                        {
                            BusinessMenuID = m.BusinessMenuID,
                            BusinessMenuName = m.BusinessMenuName
                        };

            List<SelectListItem> items = new SelectList(query.ToList(), "BusinessMenuID", "BusinessMenuName",id).ToList();

            ViewBag.items = items;

html代码:

@Html.DropDownList("mid", ViewBag.items as IEnumerable<SelectListItem>)

 

asp.net mvc SelectList使用

标签:

原文地址:http://www.cnblogs.com/zoro-zero/p/4995532.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!