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>
  • 相关阅读:
    微软首届Power Platform开发黑客松大赛
    PowerApps 简介
    PowerBI KPI 演示
    什么是Power Platform低代码
    利用Microsoft PowerApps模板,一分钟创建Service Desk服务程序
    Power Platform
    Microsoft Power Platform 低代码开发平台
    登录监听Enter键
    代理配置
    Enjoy the pain about Moloch
  • 原文地址:https://www.cnblogs.com/ceccf/p/5794582.html
Copyright © 2011-2022 走看看