zoukankan      html  css  js  c++  java
  • 一、@Html.DropDownList

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

                //查询城市
                string CityId = WebCommon.Public.GetAdminCityId();
                var CityList = WebBLL.Tbl_ClassManager.GetDataTableByPage(1000, 1, "parentid=3", "ordernum asc");
                List<SelectListItem> item1 = new List<SelectListItem>();
                var lstID = (from d in CityList.AsEnumerable() select new SelectListItem(){ Text = d["ClassName"].ToString(),Value = d["ID"].ToString() ,Selected = (d["ID"].ToString()== CityId ?true :false) });
                item1.AddRange(lstID);
                ViewBag.SubCity = item1;

      

                                    @{
                                        if (Convert.ToInt32(HttpContext.Current.Request.Cookies["CityId"].Value) != 0)
                                        {
                                            @Html.DropDownList("SubCity", null, new { @class = "input-xlarge form-control", @disabled = "disabled" });
                                        }
                                        else
                                        {
                                            @Html.DropDownList("SubCity", null, new { @class = "input-xlarge form-control" })
                                        }
                                    }
  • 相关阅读:
    Pascal's Triangle
    Pascal's Triangle II
    贪心算法入门
    Jump Game
    Symmetric Tree
    Reverse Words in a String
    [BZOJ2342][Shoi2011]双倍回文
    [HDU3068]最长回文
    [POJ1984]Navigation Nightmare
    [BZOJ3295][Cqoi2011]动态逆序对
  • 原文地址:https://www.cnblogs.com/fger/p/10910452.html
Copyright © 2011-2022 走看看