1
MVC의 드롭 다운 목록에서 값을 검색하려고하는데 테이블에서 드롭 다운 목록을 바인딩 할 수 있지만 선택한 드롭 다운 값의 ID를 저장할 수 없습니다. 데이터베이스MVC에서 드롭 다운 목록 C#
//The following is a snippet of my Create.aspx
<%= Html.dropdownlist("departments", "Select One")%>
//The following is a snippet of my HomeController.cs
public ActionResult Create()
{
this.ViewData["departments"] = new SelectList(_service.ListDepartments(), "departmentID", "name");
return View("Create");
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create(int? deptID, [Bind(Exclude = "educationID")] tblEDA empToCreate)
{
if (_service.CreateEmp(deptID, empToCreate))
return RedirectToAction("Index");
return View("Create");
}
모든 도움을 받으실 수 있습니다.
도움을 주셔서 감사합니다. –