首页 > Web开发 > 详细

asp.net mvc DropDownList

时间:2015-04-19 17:37:34      阅读:438      评论:0      收藏:0      [点我收藏+]
 ViewBag.TopicInfoID = new SelectList(db.TopicInfo, "TopicInfoID", "TopicName", strategycategory.TopicInfoID);

            var list = db.StrategyCategory.Where(p => p.StrategyCategoryParentID == "0").ToList();
            list.Insert(0, new StrategyCategory() { StrategyCategoryID = "0", StraegyCategoryName = " -- 请选择 -- " });
            SelectList sList = new SelectList(list, "StrategyCategoryID", "StraegyCategoryName",strategycategory.StrategyCategoryParentID);
            ViewBag.StrategyCategoryParentID = sList; 
 @Html.DropDownList("TopicInfoID", String.Empty)
 @Html.DropDownList("StrategyCategoryParentID", String.Empty)

备注:

1、

ViewBag.TopicInfoID中的TopicInfoID和@Html.DropDownList("TopicInfoID", String.Empty)方法中的第一个参数一样

2、
 ViewBag.StrategyCategoryParentID = sList; 

 @Html.DropDownList("StrategyCategoryParentID", String.Empty)





asp.net mvc DropDownList

原文:http://www.cnblogs.com/zoro-zero/p/4439451.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!