本文整理汇总了C#中System.Web.Mvc.SelectList类的典型用法代码示例。如果您正苦于以下问题:C# SelectList类的具体用法?C# SelectList怎么用?C# SelectList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SelectList类属于System.Web.Mvc命名空间,在下文中一共展示了SelectList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitializeAcres
private static void InitializeAcres()
{
Dictionary<string, double> acreGroups = new Dictionary<string, double>()
{
{ "Less than .25", 0.0D },
{ ".25", 0.25D },
{ ".25+", 0.26D },
{ ".33", 0.33D },
{ ".33+", 0.34D },
{ ".5", 0.5D },
{ ".5+", 0.51D },
{ ".75", 0.75D },
{ ".75+", 0.76D },
{ "1", 1.0D },
{ "1+", 1.1D },
{ "1.25", 1.25D },
{ "1.25+", 1.26D },
{ "1.33", 1.33D },
{ "1.33+", 1.34D },
{ "1.5", 1.5D },
{ "1.5+", 1.51D },
{ "2", 2.0D },
{ "2+", 2.1D },
{ "3", 3.0D },
{ "3+", 3.1D },
{ "5", 5.0D },
{ "5+", 5.1D },
{ "10", 10.0D },
{ "10+", 10.1D }
};
SelectList final = new SelectList(acreGroups, "Value", "Key");
acres = final;
}
示例2: TicketVM
public TicketVM()
{
error = "";
types = TicketType.GetTicketTypes();
ticket = new Ticket();
typeList = new SelectList(types, "ID", "Name", SelectedType);
}
示例3: Create
public ActionResult Create(CompanyAdvice companyAdvice, FormCollection form)
{
if (companyAdvice.CompanysId == null)
{
ModelState.AddModelError("CompanysId", "Please choose a company.");
}
ValidateAdvice(companyAdvice);
if (ModelState.IsValid)
{
try
{
_adviceApplicationService.AddCompanyAdvice(CurrentMentor, companyAdvice);
return RedirectToAction("Index", "Advice");
}
catch
{
return RedirectToAction("Create");
}
}
var companies = _companyApplicationService.GetAllCompanies();
ViewData["Companies"] = new SelectList(companies, "Id", "CompanyName", companyAdvice.CompanysId);
ViewData["Semaphores"] = _semaphoreApplicationService.GetAllSemaphores();
SetAdviceTagViewData();
return View(companyAdvice);
}
示例4: Approve
//
// GET: /Survey/Approve/5
public ActionResult Approve(int id)
{
try
{
if (Session["UserAccountID"] == null)
return RedirectToAction("Validate", "Login");
User user = (User)Session["User"];
ViewData["LoginInfo"] = Utility.BuildUserAccountString(user.Username, Convert.ToString(Session["UserAccountName"]));
if (user.IsAdmin)
ViewData["txtIsAdmin"] = "true";
else
ViewData["txtIsAdmin"] = "false";
Survey survey = repository.GetSurvey(id);
ViewData["ValidationMessage"] = String.Empty;
IImageRepository imgrep = new EntityImageRepository();
Image img = imgrep.GetImage(survey.SurveyImageID);
ViewData["ImageList"] = new SelectList(BuildImageList(img.StoredFilename), "Value", "Text", img.StoredFilename);
ViewData["ImageUrl"] = selectedfile;
ViewData["ImageFolder"] = ConfigurationManager.AppSettings["MediaRootFolder"] + Convert.ToString(Session["UserAccountID"]) + @"/Images/";
ViewData["SurveyTable"] = BuildSurveyTableNoLinks(survey);
return View(survey);
}
catch (Exception ex)
{
Helpers.SetupApplicationError("Survey", "Approve", ex.Message);
return RedirectToAction("Index", "ApplicationError");
}
}
示例5: IndexViewModel
public IndexViewModel()
{
From = new OptionalDateInputViewModel(true);
To = new OptionalDateInputViewModel(true);
DateSelectList = new SelectList(EnumHelper.GetValues(typeof(MissingShipmentsReportDates)), "Key", "Value", null);
}
示例6: GetViewDataWithSelectList
private static ViewDataDictionary GetViewDataWithSelectList() {
ViewDataDictionary viewData = new ViewDataDictionary();
SelectList selectList = new SelectList(MultiSelectListTest.GetSampleAnonymousObjects(), "Letter", "FullWord", "C");
viewData["foo"] = selectList;
viewData["foo.bar"] = selectList;
return viewData;
}
示例7: SetViewDataForDate
public static void SetViewDataForDate(ViewDataDictionary ViewData)
{
List<string> genderList = new List<string>();
genderList.Add("Male");
genderList.Add("Female");
SelectList list = new SelectList(genderList);
ViewData["gender"] = list;
int[] dayA = new int[31];
for (int i = 0; i < 31; i++)
{
dayA[i] = i + 1;
}
int[] yearA = new int[100];
for (int i = 0; i < 100; i++)
{
yearA[i] = DateTime.Now.Year - i;
}
SelectList daySL = new SelectList(dayA);
ViewData["days"] = daySL;
SelectList yearSL = new SelectList(yearA);
ViewData["years"] = yearSL;
}
示例8: Create
public ActionResult Create(string name, string text, string category)
{
try
{
if((name == "") || (text == "")) throw new ArgumentException("Name/Text");
Comment newComment = new Comment();
newComment.Name = name;
newComment.Text = text;
newComment.Category = new Category();
newComment.Category.Id = new Guid(category);
this._rep.CreateComment(newComment);
return RedirectToAction("Index");
}
catch
{
if (name == "") ModelState.AddModelError("Name", "Set Name");
if (text == "") ModelState.AddModelError("Text", "Set Text");
List<Category> result = this._rep.GetCategories().ToList();
SelectList select = new SelectList(result, "Id", "Name");
return View(select);
}
}
示例9: EditLink
public ActionResult EditLink(ImportantLinks model)
{
var languages = LanguageManager.GetLanguages();
var list = new SelectList(languages, "Culture", "Language");
ViewBag.LanguageList = list;
if (ModelState.IsValid)
{
if (RouteData.Values["id"] != null)
{
int nid = 0;
bool isnumber = int.TryParse(RouteData.Values["id"].ToString(), out nid);
if (isnumber)
{
model.LinkId = nid;
ViewBag.ProcessMessage = LinkManager.EditImportantLink(model);
return View(model);
}
else
{
ViewBag.ProcessMessage = false;
return View(model);
}
}
else return View();
}
else
return View();
return View();
}
示例10: Create
public ActionResult Create()
{
var user = User.Identity.GetUserId();
ViewData["TutorialSelection"] = new SelectList(db.Tutorials.Where(x => x.EducatorId == user).ToList(), "Title", "Title");
//do something to link tutID and quizID
return View();
}
示例11: Edit
public ActionResult Edit(int id)
{
var transaction = repository.Get<Transaction>(id);
var users = repository.List<User>();
ViewData["users"] = new SelectList(users, "Id", "Name", transaction.Who.Id);
return View(transaction);
}
示例12: Edit
public ActionResult Edit()
{
//1. Pasamos valores al Modelo del servicio
List<AprobarWS.Aprobar> viaticos = proxy.ListarSolicitudes();
AprobarWS.Aprobar viaticoEditar = new AprobarWS.Aprobar();
viaticoEditar.CodigoSolicitud = viaticos[0].CodigoSolicitud;
viaticoEditar.FechaSolicitud = viaticos[0].FechaSolicitud;
viaticoEditar.ubigeoOrigen = viaticos[0].ubigeoOrigen;
viaticoEditar.ubigeoDestino = viaticos[0].ubigeoDestino;
viaticoEditar.FechaSalida = viaticos[0].FechaSalida;
viaticoEditar.FechaRetorno = viaticos[0].FechaRetorno;
viaticoEditar.SustentoViaje = viaticos[0].SustentoViaje;
viaticoEditar.TotalSolicitado = viaticos[0].TotalSolicitado;
//3. Llenar combobox de Estado
var list = new[] {
new Estado { Id = "P", Name = "Pendiente" },
new Estado { Id = "A", Name = "Aprobado" }
};
var listEstados = new SelectList(list, "Id", "Name");
ViewData["estados"] = listEstados;
return View(viaticoEditar);
}
示例13: getParentPages
public SelectList getParentPages(int selectedPageID)
{
contentCMSDBDataContext db = new contentCMSDBDataContext();
var parentPages = from pp in db.pages where pp.parent == 0 && pp.isPublished == true select pp;
List<object> parentPagesList = new List<object>();
parentPagesList.Add(new
{
Id = 0,
Name = "None",
SelectedValue = 0
});
foreach (var item in parentPages)
{
parentPagesList.Add(new
{
Id = item.pageID,
Name = item.pageTitle,
SelectedValue = item.pageID
});
}
SelectList newSL = new SelectList(parentPagesList, "Id", "Name", selectedPageID);
return newSL;
}
示例14: Create
public ActionResult Create()
{
ViewData["ddGrupos"] = new SelectList(new[] { "(Selecciona)" });
ViewData["ddEmpresas"] = new SelectList(new[] { "(Selecciona)" });
ViewData["ddPerfiles"] = new SelectList(new[] { "(Selecciona)" });
return View();
}
示例15: IndexViewModel
public IndexViewModel()
{
ConsentValidFromStart = new OptionalDateInputViewModel(allowPastDates: true, showLabels: false);
ConsentValidFromEnd = new OptionalDateInputViewModel(allowPastDates: true, showLabels: false);
ConsentValidToStart = new OptionalDateInputViewModel(allowPastDates: true, showLabels: false);
ConsentValidToEnd = new OptionalDateInputViewModel(allowPastDates: true, showLabels: false);
NotificationReceivedStart = new OptionalDateInputViewModel(allowPastDates: true, showLabels: false);
NotificationReceivedEnd = new OptionalDateInputViewModel(allowPastDates: true, showLabels: false);
NotificationTypes = new SelectList(EnumHelper.GetValues(typeof(NotificationType)), dataTextField: "Value", dataValueField: "Key");
TradeDirections = new SelectList(EnumHelper.GetValues(typeof(TradeDirection)), dataTextField: "Value", dataValueField: "Key");
InterimStatus = new SelectList(new[]
{
new SelectListItem
{
Text = "Interim",
Value = "true"
},
new SelectListItem
{
Text = "Non-interim",
Value = "false"
}
}, dataTextField: "Text", dataValueField: "Value");
OperationCodes = new MultiSelectList(EnumHelper.GetValues(typeof(OperationCode)), dataTextField: "Value", dataValueField: "Key");
NotificationStatuses = new SelectList(GetCombinedNotificationStatuses(), dataTextField: "Name", dataValueField: "StatusId", dataGroupField: "TradeDirection", selectedValue: null);
SelectedOperationCodes = new OperationCode[] { };
}