MVC下拉框 一一 @Html.DropDownList使用

控制器代码

  var limitbidlist = LimitBidInfoBLL.GetLimitBidList();
            var selectItemList = new List<SelectListItem>() {
                new SelectListItem(){Value="0",Text="全部",Selected=true}
            };
            var selectList = new SelectList(limitbidlist, "AucID", "BidName");
            selectItemList.AddRange(selectList);
            ViewBag.AucIDList = selectItemList;

页面代码

 @Html.DropDownList("dpAucID", ViewBag.AucIDList as IEnumerable<SelectListItem>, new { @class = "form-control" })

 

参考网址:

https://www.cnblogs.com/CreateMyself/p/5424894.html

https://www.cnblogs.com/notevar/p/5016342.html

 

posted @ 2020-05-21 10:34  代码沉思者  阅读(284)  评论(0编辑  收藏  举报