当前位置: 首页>>代码示例>>C#>>正文


C# SelectList.Add方法代码示例

本文整理汇总了C#中System.Web.Mvc.SelectList.Add方法的典型用法代码示例。如果您正苦于以下问题:C# SelectList.Add方法的具体用法?C# SelectList.Add怎么用?C# SelectList.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.Mvc.SelectList的用法示例。


在下文中一共展示了SelectList.Add方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CategoryCreate

 public ActionResult CategoryCreate()
 {
     var user = db.dt_user.FirstOrDefault();
     if (Session["personel_id"] == null)
         return RedirectToAction("Default", "Home");
     else
     {
         int personel_id = Convert.ToInt32(Session["personel_id"]);
         user = db.dt_user.Where(a => a.state == 1 && a.ID == personel_id).FirstOrDefault();
         if (user == null)
             return RedirectToAction("Default", "Home");
         ViewBag.userName = user.name + " " + user.surname;
     }
     List<SelectListItem> listCategory = new SelectList(db.dt_category.ToList().Where(a => a.state == 1 && a.company_id == user.company_id), "ID", "name").ToList<SelectListItem>();
     SelectListItem it = new SelectListItem();
     it.Text = "Üst Kategori";
     it.Value = "0";
     listCategory.Add(it);
     ViewBag.upCategoryID = listCategory.ToList();
     return View();
 }
开发者ID:jacksparrow47,项目名称:ErrorRepotingService,代码行数:21,代码来源:CategoryController.cs

示例2: _EditSearchedTerms

        public ActionResult _EditSearchedTerms(long id, string term, string searchTypeCode)
        {
            IEnumerable<ISearcher> searchers = SearcherFactory.GetDisplaySearchers();
            if (searchers != null)
            {
                List<SelectListItem> itemList = new SelectList(searchers.Select(n => new { text = n.Name, value = n.Code }), "value", "text", searchTypeCode).ToList();
                bool selectedGlobal = false;
                if (searchTypeCode == SearcherFactory.GlobalSearchCode)
                {
                    selectedGlobal = true;
                }
                itemList.Add(new SelectListItem { Text = SearcherFactory.GlobalSearchName, Value = SearcherFactory.GlobalSearchCode, Selected = selectedGlobal });
                ViewData["searchList"] = itemList;
            }

            ViewData["id"] = id;

            return View();
        }
开发者ID:hbulzy,项目名称:SYS,代码行数:19,代码来源:ControlPanelOperationController.cs

示例3: DownloadReports

        public ActionResult DownloadReports()
        {
            var data = db.TeamReports.DistinctBy(t => t.Round);

            var i = new SelectList(data, "Round", "Round").ToList();
            i.Add(new SelectListItem { Text = "全部报告", Value = "" });
            ViewBag.List = i;

            return View();
        }
开发者ID:Self-Education-Association,项目名称:SITE,代码行数:10,代码来源:AdministratorController.cs

示例4: CategoryCreate

 public ActionResult CategoryCreate(int? Id, int? mesaj)
 {
     if (Session["user_id"] == null)
         return RedirectToAction("Default", "Home");
     int user_id = Convert.ToInt32(Session["user_id"].ToString());
     var u = db.dt_user.Where(a => a.state == 1 && a.ID == user_id).FirstOrDefault();
     if (u == null)
         return RedirectToAction("Default", "Home");
     ViewBag.userName = u.name + " " + u.surname;
     if (mesaj != null)
         TempData["mesaj"] = mesaj.ToString();
     int companyId;
     if (Id == null)
         companyId = 0;
     else
         companyId = (int)Id;
     List<SelectListItem> list = TumSirket(companyId);
     int companyid;
     if (Id == null)
         companyid = Convert.ToInt32(list.ToList().First().Value);
     else
         companyid = companyId;
     List<SelectListItem> listCategory = new SelectList(db.dt_category.ToList().Where(a => a.state == 1 && a.company_id == companyid), "ID", "name").ToList<SelectListItem>();
     SelectListItem it = new SelectListItem();
     it.Text = "Üst Kategori";
     it.Value = "0";
     listCategory.Add(it);
     ViewBag.company_id = list.ToList();
     ViewBag.upCategoryID = listCategory.ToList();
     return View();
 }
开发者ID:jacksparrow47,项目名称:ErrorRepotingService,代码行数:31,代码来源:AdminPanelController.cs

示例5: SirketGoster

 public void SirketGoster(int Id, int parentId)
 {
     List<SelectListItem> list = new SelectList(db.dt_company.ToList().Where(a => a.active == 1 && a.ID != Id && a.parentID != Id), "ID", "companyname", parentId).ToList<SelectListItem>();
     SelectListItem it = new SelectListItem();
     it.Text = "Merkezi Şirket";
     it.Value = "0";
     list.Add(it);
     if (parentId == 0)
         list.Reverse();
     ViewBag.companyId = list.ToList();
 }
开发者ID:jacksparrow47,项目名称:ErrorRepotingService,代码行数:11,代码来源:AdminPanelController.cs

示例6: EditarAsignacion

        // GET: Curso/EditarAsignacion/5
        public ActionResult EditarAsignacion(int? id)
        {
            if (Request.UrlReferrer != null)
            {
                ViewBag.returnUrl = Request.UrlReferrer.ToString();
            }
            else
            {
                ViewBag.returnUrl = null;
            }
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            Group grupo = db.Groups.Find(id);
            if (grupo == null)
            {
                return HttpNotFound();
            }

            /* Se obtiene la lista de profesores */
            List<SelectListItem> vSelectList = new SelectList(db.Professors.OrderBy(p => p.Name), "ID", "Name").ToList();
            SelectListItem selListItem = new SelectListItem() { Value = "0", Text = "Sin asignar" };
            vSelectList.Add(selListItem);

            ViewBag.Profesores = vSelectList;
            return View(grupo);
        }
开发者ID:saca-ae,项目名称:SACA-AE_Web-App_v2,代码行数:29,代码来源:CursoController.cs


注:本文中的System.Web.Mvc.SelectList.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。