本文整理汇总了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;
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}