zoukankan      html  css  js  c++  java
  • MVC要点

    1.绑定一个DropDownList

    @Html.DropDownListFor(m => m.MobileType, new List<SelectListItem>() { new SelectListItem { Value = "0", Text = "中国电信" }, new SelectListItem { Value = "1", Text = "中国联通" }, new SelectListItem { Value = "2", Text = "中国移动" } }, new { @class = "easyui-combobox", @editable = "false"  })

    2.绑定一个emun   

    2.1     

    public enum GroupChannelEnum
    {
    [Description("==请选择==")]
    empty =0,
    [Description("是")]
    yes =1,
    [Description("否")]
    no = 2
    }

    2.2:控制器

    Dictionary<string, object> ChannelDic = GetEnum.EnumListDic<GroupChannelEnum>("", "");
    ViewBag.ChannelList = new SelectList(ChannelDic, "value", "key");

    2.3前台

    @Html.DropDownListFor(m => m.ChannelName,ViewBag.ChannelList as IEnumerable<SelectListItem>,new { @class = "easyui-combobox", @editable = "false"  })

    l另一种方法:控制器

    DataTable dt = new KFAdd().GetComplaintSourceList();
    List<SelectListItem> ComplaintSourceList = new List<SelectListItem>();
    for (int i = 0; i < dt.Rows.Count;i++ ) {
    if (dt.Rows[i]["FCSName"].ToString() == model.ComplaintSource)
    {
    ComplaintSourceList.Add(new SelectListItem { Text = dt.Rows[i]["FCSName"].ToString(), Value = dt.Rows[i]["FCSID"].ToString(), Selected = true });
    }
    else {
    ComplaintSourceList.Add(new SelectListItem { Text = dt.Rows[i]["FCSName"].ToString(), Value = dt.Rows[i]["FCSID"].ToString() });
    }

    }

    前台

    @Html.DropDownListFor(m => m.ChannelName,ViewBag.ChannelList as IEnumerable<SelectListItem>,new { @class = "easyui-combobox", @editable = "false"  })

  • 相关阅读:
    详说清除浮动
    ie7 z-index 失效问题
    ul里不能直接嵌套div(在ie7以前版本)
    jQuery 发送验证码倒计时按钮
    VBA: Cant find project or librar
    InstallShield Limited Edition制作安装文件
    InstallShield制作升级安装包
    VBA 获取Sheet最大行
    求两条线段交点zz
    VBA找不到progress bar的处理办法。
  • 原文地址:https://www.cnblogs.com/lacey/p/7083512.html
Copyright © 2011-2022 走看看