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


C# Rendering.SelectList类代码示例

本文整理汇总了C#中Microsoft.AspNet.Mvc.Rendering.SelectList的典型用法代码示例。如果您正苦于以下问题:C# SelectList类的具体用法?C# SelectList怎么用?C# SelectList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SelectList类属于Microsoft.AspNet.Mvc.Rendering命名空间,在下文中一共展示了SelectList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ApportionViewModel

        public ApportionViewModel(int selectedMonth, int selectedYear)
        {
            ApportionItems = new List<ApportionItem>();
            AccountOwners = OwnerNames.Owners;

            var lstMonths = new List<DateDropdownItem>();
            for (int i = 1; i <= 12; i++)
            {
                lstMonths.Add(new DateDropdownItem { MonthInt = i });
            }

            var lstYears = new List<int>();
            for (int i = 2012; i < 2017; i++)
            {
                lstYears.Add(i);
            }


            selectedMonth = selectedMonth > 0 ? selectedMonth : DateTime.Now.Month;
            selectedYear = selectedYear > 0 ? selectedYear : DateTime.Now.Year;

            Months = new SelectList(lstMonths, "MonthInt", "MonthName");
            Years = new SelectList(lstYears, selectedYear);
            SelectedMonth = selectedMonth;
            SelectedYear = selectedYear;
        }
开发者ID:ajithmohann,项目名称:MakeItClear,代码行数:26,代码来源:ApportionViewModel.cs

示例2: Create

 // GET: Funcionarios/Create
 public IActionResult Create()
 {
     ViewData["departamentoId"] = new SelectList(_context.Departamentos, "Id", "departamento");
     ViewData["empresaId"] = new SelectList(_context.Empresas, "codigo", "empresa");
     ViewData["utilizadorId"] = new SelectList(_context.Users, "Id", "utilizador");
     return View();
 }
开发者ID:gmahota,项目名称:CRM_MIT,代码行数:8,代码来源:FuncionariosController.cs

示例3: Create

 // GET: Students/Create
 public IActionResult Create()
 {
     ViewData["FirstNameId"] = new SelectList(_context.Set<FirstName>(), "FirstNameId", "FirstName");
     ViewData["LastNameId"] = new SelectList(_context.Set<LastName>(), "LastNameId", "LastName");
     ViewData["MidNameId"] = new SelectList(_context.Set<MidName>(), "MidNameId", "MidName");
     return View();
 }
开发者ID:cornFedir,项目名称:Uni,代码行数:8,代码来源:StudentsController.cs

示例4: Create

 // GET: ComicsPersons/Create
 public IActionResult Create()
 {
     ViewData["ComicsId"] = new SelectList(_context.Comicses, "Id", "Comics");
     ViewData["PersonId"] = new SelectList(_context.Persons, "Id", "Person");
     ViewBag.Category = new SelectList(_context.PersonTypes, "Id", "Title");
     return View();
 }
开发者ID:LestatDelionkur,项目名称:Comix,代码行数:8,代码来源:ComicsPersonsController.cs

示例5: Create

 // GET: Benchmarks/Create
 public IActionResult Create()
 {
     ViewData["ActualReportId"] = new SelectList(_context.ActualReports, "Id", "ActualReport");
     ViewData["BenchmarkContainerId"] = new SelectList(_context.BenchmarkContainers, "Id", "BenchmarkContainer");
     ViewData["ExpectedReportId"] = new SelectList(_context.ExpectedReports, "Id", "ExpectedReport");
     return View();
 }
开发者ID:AaronDeSanctis,项目名称:Simpl,代码行数:8,代码来源:BenchmarksController.cs

示例6: Create

 // GET: Posts/Create
 public IActionResult Create()
 {
     ViewData["ForumId"] = new SelectList(_context.Forums, "Id", "Name");
     ViewData["ReplyToPostId"] = new SelectList(_context.Posts, "ReplyToPostId", "ReplyToPostId");
     ViewData["UserId"] = new SelectList(_context.Users, "Id", "UserName");
     return View();
 }
开发者ID:gdoron,项目名称:Forums,代码行数:8,代码来源:PostsController.cs

示例7: Index

        // GET: Movies
        public IActionResult Index(string movieGenre, string searchString)
        {
            fakeData1();

            Debug.WriteLine("\n CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\n    searchString = >" + searchString + "<\n    movieGenre = >" + movieGenre + "<");

            //return View(_context.Movie.ToList());
            var GenreQry = from m in movieList
                           orderby m.Genre
                           select m.Genre;

            var GenreList = new List<string>();
            GenreList.AddRange(GenreQry.Distinct());
            ViewData["movieGenre"] = new SelectList(GenreList);

            Debug.WriteLine("Genre count is " +GenreList.Count);

            // var movies = from m in movieList select m;
            var movieListShort = from m in movieList select m;

            if (!String.IsNullOrEmpty(searchString))
            {
                movieListShort = movieListShort.Where(s => s.Title.Contains(searchString));  // s => s.Title is a Lambda Expression. This is case sensitive.
            }

            if(!string.IsNullOrEmpty(movieGenre))
            {
                movieListShort = movieListShort.Where(x => x.Genre == movieGenre);
            }

            return View(movieListShort);
        }
开发者ID:Spencerinc,项目名称:VS_MvcMovie,代码行数:33,代码来源:MoviesController.cs

示例8: Create

 // GET: Expenses/Create
 public IActionResult Create()
 {
     ViewData["FakeTransactionsId"] = new SelectList(_context.FakeTransactions, "Id", "FakeTransactions");
     ViewData["TodaysTransactionsId"] = new SelectList(_context.TodaysTransactions, "Id", "TodaysTransactions");
     ViewData["TotalTransactionsId"] = new SelectList(_context.TotalTransactions, "Id", "TotalTransactions");
     return View();
 }
开发者ID:AaronDeSanctis,项目名称:Simpl,代码行数:8,代码来源:ExpensesController.cs

示例9: SaveTransaction

        public IActionResult SaveTransaction(QuickTransactionViewModel vm)
        {
            if (ModelState.IsValid == false)
            {
                vm.SelectedTransaction = accountsService.GetQuickTransactionDef(long.Parse(vm.SelectedTransaction)).Name;

                var accountHeads = accountsService.GetAllAccountHeadsByCurrency(HttpContext.Session.GetString("Currency"));
                var accountHeadsList = new SelectList(accountHeads, "AccountHeadId", "Name");
                vm.AccountHeads = accountHeadsList;

                return View("CreateTransaction", vm); 
            }

            Journal item = new Journal()
            {
                Amount = vm.Amount,
                CrAccountHeadId = vm.CrAccountHeadId,
                DrAccountHeadId = vm.DrAccountHeadId,
                Narration = vm.Narration,
                TransactionDate = vm.TransactionDate,
                ModifiedBy = "testuser", // TODO: replace with log in user id
                ModifiedDate = DateTime.Now
            };

            journalService.CreateJournal(item);

            return View("TransactionResult", item);
        }
开发者ID:ajithmohann,项目名称:MakeItClear,代码行数:28,代码来源:TransactionController.cs

示例10: Index

        // GET: Movies
        public IActionResult Index(string movieGenre, string searchString)
        {
            var GenreQry = from m in _context.Movie
                           orderby m.Genre
                           select m.Genre;

            var GenreList = new List<string>();
            GenreList.AddRange(GenreQry.Distinct());
            ViewData["movieGenre"] = new SelectList(GenreList);

            var movies = from m in _context.Movie
                         select m;

            if (!string.IsNullOrEmpty(searchString))
            {
                movies = movies.Where(s => s.Title.Contains(searchString));
            }

            if (!string.IsNullOrEmpty(movieGenre))
            {
                movies = movies.Where(x => x.Genre == movieGenre);
            }

            return View(movies);
        }
开发者ID:p-murphy,项目名称:MvcMovie,代码行数:26,代码来源:MoviesController.cs

示例11: Index

        public IActionResult Index(string currencyCode)
        {
            var currencies = HttpContext.Session.GetObjectFromJson<List<Currency>>("Currencies");
            var curSelVal = currencyService.GetDefaultCurrency().CurrencyCode;
            var currencyList = new SelectList(currencies, "CurrencyCode", "CurrencyCode", curSelVal);

            var vm = new ChangeCurrencyViewModel(currencyList);
            return View(vm);
        }
开发者ID:ajithmohann,项目名称:MakeItClear,代码行数:9,代码来源:AdminController.cs

示例12: ChangeCurrency

        public IActionResult ChangeCurrency(string currencyCode)
        {
            var currencies = HttpContext.Session.GetObjectFromJson<List<Currency>>("Currencies");
            var curSelVal = currencies.First(x => x.CurrencyCode.Equals(currencyCode)).CurrencyCode;
            var currencyList = new SelectList(currencies, "CurrencyCode", "CurrencyCode", curSelVal);

            var vm = new ChangeCurrencyViewModel(currencyList);
            return View(vm);
        }
开发者ID:ajithmohann,项目名称:MakeItClear,代码行数:9,代码来源:HomeController.cs

示例13: Edit

 public async Task<ActionResult> Edit(int id)
 {
     FieldRule fieldRule = await FindAsyncFieldRule(id);
     if (fieldRule == null)
     {
         return HttpNotFound();
     }
     ViewData["SpiderId"] = new SelectList(ProjectContext.Projects, "Id", "Name", fieldRule.SpiderId);
     return View(fieldRule);
 }
开发者ID:DubMircea,项目名称:ttt,代码行数:10,代码来源:FieldRuleControllers.cs

示例14: Create

 public IActionResult Create(TvProgramEpisode tvProgramEpisode)
 {
     if (ModelState.IsValid) {
         _context.TvEpisodes.Add(tvProgramEpisode);
         _context.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewData["TvProgramId"] = new SelectList(_context.TvPrograms, "TvProgramId", "TvProgram", tvProgramEpisode.TvProgramId);
     return View(tvProgramEpisode);
 }
开发者ID:olliholliday,项目名称:TvList,代码行数:10,代码来源:TvProgramEpisodesController.cs

示例15: Create

 public async Task<IActionResult> Create(Comics comics)
 {
     if (ModelState.IsValid)
     {
         _context.Comicses.Add(comics);
         await _context.SaveChangesAsync();
         return RedirectToAction("Index");
     }
     ViewData["ParentComicsId"] = new SelectList(_context.Comicses, "Id", "ParentComics", comics.ParentComicsId);
     return View(comics);
 }
开发者ID:LestatDelionkur,项目名称:Comix,代码行数:11,代码来源:ComicsController.cs


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