后台:
无默认值:
ViewBag.Project = new SelectList(db.SYS_DD.Where(dd => dd.DDType == "Project").OrderBy(dd => dd.DDCode), "DDCode", "DDName");
有默认值:
ViewBag.Project = new SelectList(db.SYS_DD.Where(dd => dd.DDType == "Project").OrderBy(dd => dd.DDCode), "DDCode", "DDName", hours.Project);
前台
@Html.DropDownList("Project", null, "-- Choose --", new { @class = "form-control" })