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

            //查询城市
string CityId = WebCommon.Public.GetAdminCityId();
var CityList = WebBLL.Tbl_ClassManager.GetDataTableByPage(, , "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) != )
{
@Html.DropDownList("SubCity", null, new { @class = "input-xlarge form-control", @disabled = "disabled" });
}
else
{
@Html.DropDownList("SubCity", null, new { @class = "input-xlarge form-control" })
}
}

一、@Html.DropDownList的更多相关文章

  1. Asp.Net 将枚举类型(enum)绑定到ListControl(DropDownList)控件

    在开发过程中一些状态的表示使用到枚举类型,那么如何将枚举类型直接绑定到ListControl(DropDownList)是本次的主题,废话不多说了,直接代码: 首先看工具类代码: /// <su ...

  2. DropDownList 下拉框选择改变,促发事件和防全局刷新(记录)

    代码: <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:Script ...

  3. DropDownList实现可输入可选择

    1.js版本 <div style="z-index: 0; visibility: visible; clip: rect(0px 105px 80px 85px); positio ...

  4. js给DropdownList赋值

    ", "model": "APOLLO M/B1"}]; ; i < row.length; i++) { var addOption = do ...

  5. ASP.NET MVC 让@Html.DropDownList显示默认值

    在使用@Html.DropDownList的过程中,发现它的用法很局限,比如在加载的时候显示设定的默认项或者调整它的显示样式,在网上查了一些资料,终于把这个问题解决了. 一.View代码 @using ...

  6. GridView中实现DropDownList联动

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...

  7. "不能在 DropDownList 中选择多个项。"其解决办法及补充

    探讨C#.NET下DropDownList的一个有趣的bug及其解决办法 摘要: 本文就C#.Net 环境下Web开发中经常使用的DropDownList控件的SelectedIndex属性进行了详细 ...

  8. Asp.net mvc页面传值-- dropdownlist

    后台传值 List<ConfigParamInfo> paramList = configParamBLL.GetModelList(" and parentID=1" ...

  9. 怎么取得dropdownlist选中的ID值

    把数据库绑定在dropdownlist中,然后把选中的dropdownlist的项的ID值保存在另外的一个数据库中.怎么取得dropdownlist选中的ID值呢?? this.DropDownLis ...

  10. MVC5中后台提供Json,前台处理Json,绑定给Dropdownlist的例子

    MVC5中后台提供Json,前台处理Json,绑定给Dropdownlist的例子: 前端: 我们以前在前端定义了两个控件: <div class="row"> < ...

随机推荐

  1. Tomcat-部署多个项目(不同端口)

    20190713  整理 参考文档 https://blog.csdn.net/chenchunlin526/article/details/78799772 如何在Tomcat服务中,为不同端口部署 ...

  2. Swift--Unmanaged使用

    Unmanaged使用 作者 Nate Cook 翻译者 Croath Liu 2015年4月13日        API 对于开发者来说不只是把功能点接口暴露出来而已,同时也传达给我们一些其他的信息 ...

  3. C++ KMP文本匹配

    代码如下: 环境为VC #include <iostream> #include <algorithm> #include <string> #include &l ...

  4. Navicat Premium 12 如何连接阿里云虚拟主机SQL Server 数据库

    这个是一台 阿里云购买云虚拟主机!密码已经重置完毕,现在我们 需要知道 数据连接的地址,数据库名,帐号以及密码. 根据不同的运营商 选择 这里我们选择阿里云 云数据库 SQL Server版本 填写 ...

  5. Ext js-01 -helloworld

    一.下载ext: 登陆这个网址  https://www.sencha.com/products/evaluate/ 下载下来解压后如下:安装cmd程序 二.开始helloworld 新建一个idea ...

  6. 【HDOJ6606】Distribution of books(二分,BIT)

    题意:给定一个长为n的数组,要求挑它前缀的一段,将其分成k段,使得每段和的最大值最小 1<=k<=n<=2e5,abs(a[i])<=1e9 思路: 刚开始写了线段树TLE 改 ...

  7. html标签内部简单加js 一维数组求最大值 最小值两个值位置和数字金字塔图形

     html标签内部,简单加js <a href=""></a><!DOCTYPE html PUBLIC "-//W3C//DTD XHTM ...

  8. Linux基本常用命令|ubuntu获取root权限

    我用的是ubuntu12.4系统,因为默认是没有获取root的权限的 下边讲解怎么获取root权限 在终端中输入: sudo passwd root Enter new UNIX password: ...

  9. MySQL新建数据库时utf8_general_ci编码解释

    utf8_unicode_ci和utf8_general_ci对中英文来说没有实质的差别.utf8_general_ci: 校对速度快,但准确度稍差.utf8_unicode_ci: 准确度高,但校对 ...

  10. Intel processor brand names-Xeon,Core,Pentium,Celeron----Xeon

    http://en.wikipedia.org/wiki/Comparison_of_Intel_processors Processor Series Nomenclature Code Name ...