一、@Html.DropDownList

一、Html.DropDownList 通过linq 将datatable转换下拉列表

            var CityList = WebBLL.Tbl_ClassManager.GetDataTableByPage(1000, 1, "parentid=3", "ordernum asc");
            List<SelectListItem> item1 = new List<SelectListItem>();
            //CityList = CityList.
            var lstID = (from d in CityList.AsEnumerable() select
                              new SelectListItem()
                              {
                                  Text = d["ClassName"].ToString(),
                                  Value = d["ID"].ToString(),
                               });
            item1.AddRange(lstID);
 @Html.DropDownList("CityOrigin", null, new { @class = "input-xlarge form-control" })

  

猜你喜欢

转载自www.cnblogs.com/fger/p/10910452.html