zoukankan      html  css  js  c++  java
  • c# 从数据库作为下拉列 删除重复的列 foreach()

     1   public ActionResult Index(YearCheckInfoRequest request)
     2         {
     3             //int a = -1;
     4             // if (request.DisasterScale == a.ToString()) { request.DisasterScale = null; };
     5             // if (request.MineName == a.ToString()) { request.MineName = null; };
     6             var result = this.YearCheckService.GetYearCheckList(request);
     7 
     8             YearCheckInfoRequest NewRequest = new YearCheckInfoRequest();
     9             Dictionary<int, String> dictionary = new Dictionary<int, string>();
    10             var MineNameList = this.YearCheckService.GetYearCheckList(NewRequest);
    11            
    12             int i = 0;
    13             List<String> mineNameList= new List<String>();
    14             
    15             foreach (YearCheckInfo yearCheck in MineNameList)
    16             {
    17                 if (!mineNameList.Contains(yearCheck.MineName))
    18                 {
    19                     mineNameList.Add(yearCheck.MineName);
    20                     dictionary.Add(i, yearCheck.MineName);
    21                     i++;
    22                 }
    23             }
    24             this.ViewBag.MineName = new SelectList(dictionary, "", "value ");
    25 
    26             //默认查询日期
    27             ViewBag.CheckTimeStart = request.CheckTimeStart.ToString("yyyy-MM-dd");
    28             ViewBag.CheckTimeEnd = request.CheckTimeEnd.ToString("yyyy-MM-dd");
    29 
    30             return View(result);
    31         }
    1   <label>
    2                     <span>矿山名称:</span>
    3                     @Html.DropDownList("MineName", ViewBag.MineName as SelectList, "所有记录",new { @class = "m-wrap medium" })
    4                   
    5                 </label>
  • 相关阅读:
    redis的数据持久化再讲 关于redisAOF RDB工作原理
    关于redis的持久化数据 RDB,AOF
    关于redis
    docker-compose的使用
    dockerfile定制镜像的使用
    docker常用命令
    关于这两天
    eclipse tomcat找不到或无法加载
    关于jdk代理和cglib代理
    scp 跨机远程拷贝
  • 原文地址:https://www.cnblogs.com/ceccf/p/5794582.html
Copyright © 2011-2022 走看看