本文整理汇总了C#中System.Web.Mvc.SelectList类的典型用法代码示例。如果您正苦于以下问题:C# SelectList类的具体用法?C# SelectList怎么用?C# SelectList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SelectList类属于System.Web.Mvc命名空间,在下文中一共展示了SelectList类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:wes-cutting,项目名称:Sandbox-V2,代码行数:33,代码来源:Acres.cs
示例2: TicketVM
public TicketVM()
{
error = "";
types = TicketType.GetTicketTypes();
ticket = new Ticket();
typeList = new SelectList(types, "ID", "Name", SelectedType);
}
开发者ID:Krynox,项目名称:2NCMTCSharp,代码行数:7,代码来源:TicketVM.cs
示例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);
}
开发者ID:consumentor,项目名称:Server,代码行数:28,代码来源:CompanyAdviceController.cs
示例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");
}
}
开发者ID:rtegarp,项目名称:TugasAkhir,代码行数:34,代码来源:SurveyController.cs
示例5: IndexViewModel
public IndexViewModel()
{
From = new OptionalDateInputViewModel(true);
To = new OptionalDateInputViewModel(true);
DateSelectList = new SelectList(EnumHelper.GetValues(typeof(MissingShipmentsReportDates)), "Key", "Value", null);
}
开发者ID:EnvironmentAgency,项目名称:prsd-iws,代码行数:7,代码来源:IndexViewModel.cs
示例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;
}
开发者ID:jesshaw,项目名称:ASP.NET-Mvc-3,代码行数:7,代码来源:SelectExtensionsTest.cs
示例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;
}
开发者ID:Ripudamangithub,项目名称:saringan-suarez-dayrit,代码行数:28,代码来源:ProfileController.cs
示例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);
}
}
开发者ID:davidalmas,项目名称:Samples,代码行数:26,代码来源:GuestbookController.cs
示例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();
}
开发者ID:miyamotomusashi,项目名称:argemsan,代码行数:32,代码来源:LinkController.cs
示例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();
}
开发者ID:tjgrist,项目名称:Tutorial-Hub,代码行数:7,代码来源:QuizController.cs
示例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);
}
开发者ID:chethan,项目名称:lekkachara,代码行数:7,代码来源:TransactionController.cs
示例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);
}
开发者ID:cgalindo20,项目名称:control-viaticos-dsd-20141,代码行数:26,代码来源:AprobarController.cs
示例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;
}
开发者ID:asipahio,项目名称:ContentCMS,代码行数:25,代码来源:Admin.cs
示例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();
}
开发者ID:xblizz,项目名称:ProyectoSistemasInformacion,代码行数:7,代码来源:UsuarioController.cs
示例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[] { };
}
开发者ID:EnvironmentAgency,项目名称:prsd-iws,代码行数:29,代码来源:IndexViewModel.cs
示例16: TestForm
// [HttpPost]
public ActionResult TestForm(/*[Bind(Exclude="Logintime")]GuestbookForm gbook*/
/*FormCollection form*/)
{
// if ( !ModelState.IsValid ) {
// return View();
// }
//ViewData.Model = form["Confirmedpassword"];
// return RedirectToAction("Index", "Home");
//GuestbookForm gbook = new GuestbookForm();
////UpdateModel<GuestbookForm>(gbook);
//if (!TryUpdateModel<GuestbookForm>(gbook))
//{
// // 模型連結發生失敗
// return View();
//}
//return Redirect("/");
///////////////////////
//Dictionary<string, object> attr = new Dictionary<string, object>();
//attr.Add("size", "16");
//attr.Add("style", "color:red;");
//ViewData["Dictionary"] = attr;
//////////////////////
List<SelectListItem> listItem = new List<SelectListItem>();
listItem.Add(new SelectListItem { Text ="是", Value = "1"});
listItem.Add(new SelectListItem { Text = "否", Value = "0" });
ViewData["List"] = new SelectList(listItem, "Value", "Text", "");
return View();
}
开发者ID:kdr130,项目名称:MvcGuestbook,代码行数:34,代码来源:GuestbookController.cs
示例17: Create
// GET: /QuizGroup/Create
public ActionResult Create()
{
var x = new SelectList(Enum.GetValues(typeof(GroupType)));
ViewBag.GroupTypes = x;
return View();
}
开发者ID:dwi-tanto-p,项目名称:Cashflow,代码行数:8,代码来源:RegularGroupController.cs
示例18: EditDocument
public ActionResult EditDocument()
{
if (RouteData.Values["id"] != null)
{
int nid = 0;
bool isnumber = int.TryParse(RouteData.Values["id"].ToString(), out nid);
if (isnumber)
{
Document record = DocumentManager.GetDocumentById(nid);
var languages = LanguageManager.GetLanguages();
var list = new SelectList(languages, "Culture", "Language", record.Language);
ViewBag.LanguageList = list;
var groups = DocumentManager.GetDocumentGroupList(record.Language);
var grouplist = new SelectList(groups, "DocumentGroupId", "GroupName", record.DocumentGroupId);
ViewBag.GroupList = grouplist;
return View(record);
}
else
return View();
}
else
return View();
}
开发者ID:miyamotomusashi,项目名称:argemsan,代码行数:25,代码来源:DocumentsController.cs
示例19: AbstractEventViewModel
public AbstractEventViewModel()
{
StartDate = DateTime.Today.Date.ToString("MM-dd-yyyy");
EndDate = DateTime.Today.Date.ToString("MM-dd-yyyy");
StartTimes = new SelectList(Constants.Constants.GetTimes(), "Value", "Key");
EndTimes = new SelectList(Constants.Constants.GetTimes(), "Value", "Key");
}
开发者ID:henryksarat,项目名称:Have-A-Voice,代码行数:7,代码来源:EventViewModel.cs
示例20: GetUsuarioByTipoId
public ActionResult GetUsuarioByTipoId(int tipoid)
{
usuarioModel modeloUsuario = new usuarioModel();
if (tipoid == 1)
{
//modeloUsuario.listaUsuarios = negAdministrador.Instancia.ListarAdministradoresPorTipo();
}
else if (tipoid == 2)
{
List<entUsuarioComun> objUsuarios = new List<entUsuarioComun>();
objUsuarios = negMedico.Instancia.ListarMedicosPorIdTipo(2);
SelectList obgUsuarios = new SelectList(objUsuarios, "idUsuario", "nombre");
return Json(obgUsuarios);
}
else if (tipoid == 3)
{
}
else if (tipoid == 4)
{
List<entUsuarioComun> objUsuarios = new List<entUsuarioComun>();
objUsuarios = negPaciente.Instancia.ListarPacientesPorIdTipo(4);
SelectList obgUsuarios = new SelectList(objUsuarios, "idUsuario", "nombre");
return Json(obgUsuarios);
}
return View();
}
开发者ID:samirmorales,项目名称:SistemaDeGestionDePacientes,代码行数:30,代码来源:UsuarioController.cs
注:本文中的System.Web.Mvc.SelectList类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论