后台代码: public class DropController : Controller { // GET: Drop public ActionResult Index() { List<Province> list = new List<Province> { new Province{ Id=1,name="山西省"}, new Province{ Id=1,name="广东省"}, new Province{ Id=1,name=…
一.非强类型: Controller: ViewData["AreId"] = from a in rp.GetArea() select new SelectListItem { Text=a.AreaName, Value=a.AreaId.ToString() }; View: @Html.DropDownList("AreId") 还可以给其加上一个默认选项:@Html.DropDownList("AreId", "请选择&qu…
Mvc中DropDownList 和DropDownListFor的常用方法 一.非强类型: Controller:ViewData["AreId"] = from a in rp.GetArea() select new SelectListItem { Text=a.AreaName, Value=a.…
方法一 Controller 部分代码: public ActionResult Modify(int id) { //3.1.1 检查id //3.1.2根据id查询数据 Models.Student stu = (from s in db.Students where s.Id == id select s).FirstOrDefault(); //方法一.查询班级数据,并 做成 下拉框 选项集合 //List<Models.Class> listClass = (from c in d…