@Html.DropDownListFor(x => x.WillAttend, new[] { new SelectListItem() {Text = "Yes, I'll be there", Value = bool.TrueString}, new SelectListItem() {Text = "No, I can't come", Value = bool.FalseString} }, "Choose an option"…
Mvc中DropDownList 和DropDownListFor的常用方法 一.非强类型: Controller:ViewData["AreId"] = from a in rp.GetArea() select new SelectListItem { Text=a.AreaName, Value=a.…
Asp.Net MVC中DropDownListFor的用法 在Asp.Net MVC中可以用DropDownListFor的方式来让用户选择已定列表中的一个数值.用法不复杂,这里简单做一个记录. 首先我们要定义一个 Model ,用户在 DropDownList 中选择指定的值赋给属性 ReadyTimeHour public class EricSunModel { public string ReadyTimeHour { get; set; } } Model定义完毕之后,接下来处理…