本文整理汇总了C#中System.Web.Mvc.SelectList.Where方法的典型用法代码示例。如果您正苦于以下问题:C# SelectList.Where方法的具体用法?C# SelectList.Where怎么用?C# SelectList.Where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Mvc.SelectList
的用法示例。
在下文中一共展示了SelectList.Where方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SchemeViewModel
public SchemeViewModel()
{
var obligationTypeNone = EA.Weee.Core.Shared.ObligationType.None.ToString();
var allObligationTypes = new SelectList(EnumHelper.GetValues(typeof(ObligationType)), "Key", "Value");
ObligationTypeSelectList = new SelectList(allObligationTypes.Where(x => x.Text != obligationTypeNone).ToList(), "Value", "Text");
StatusSelectList = new SelectList(EnumHelper.GetValues(typeof(SchemeStatus)), "Key", "Value");
Status = SchemeStatus.Pending;
IsChangeableStatus = false;
}
示例2: SelectList
public static SelectList SelectList(IEnumerable items, string valueField, string textField, string nullText, string selectedValue)
{
var list = new SelectList(items, valueField, textField, selectedValue).ToList();
var selected = list.Where(x => x.Value == selectedValue).FirstOrDefault();
if (selected != null) selected.Selected = true;
if (nullText != null) list.Insert(0, new SelectListItem { Text = nullText, Value = 0.ToString() });
return new SelectList(list, "Value", "Text", selectedValue);
}
示例3: Edit
//
// GET: /Pages/Edit/5
public ActionResult Edit(int id = 0)
{
Pages pages = db.Pages.Find(id);
if (pages == null)
{
return HttpNotFound();
}
SelectList Parent = new SelectList(db.Pages, "Id", "Name");
ViewBag.FK_Parent = Parent.Where(p => p.Value != pages.Id.ToString()).ToList(); //new SelectList(db.Pages, "Id", "Name", pages.FK_Parent);
ViewBag.FK_Status = new SelectList(db.Status, "Id", "Name", pages.FK_Status);
var Templates = from DA.Helpers.Templates s in Enum.GetValues(typeof(DA.Helpers.Templates)) select new { ID = (int)s, Name = s.ToString() };
ViewData["PageTemplate"] = new SelectList(Templates, "ID", "Name", pages.PageTemplate);
return View(pages);
}