當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。