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"  })

  • 相关阅读:
    logback 指定每隔一段时间创建一个日志文件
    常用Linux命令
    Java stream的常见用法
    spring boot 整合js css 静态文件
    UnityWebRequest http post json通信
    spring boot 添加拦截器实现登陆检测
    游戏服务器业务处理线程管理
    netty如何实现零拷贝
    游戏服务器性能调优常用工具详解
    Java UTC时间与本地时间互相转换
  • 原文地址:https://www.cnblogs.com/lacey/p/7083512.html
Copyright © 2011-2022 走看看