.net mvc
how to get records from database in dropdownlist using asp.net mvc
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Ranjit PowarRank #553 · 4.4K reputationPosted Jan 1, 2016, 12:03 AM EST
Ankur MistryRank #86 · 23.9K reputationPosted Jan 1, 2016, 5:50 AM EST
Jithil JohnRank #2,791 · 506 reputationPosted Feb 11, 2016, 7:41 PM EST
{
[Key]
public int EmployeeID { get; set; }
public int DepartmentID { get; set; }
public virtual Department Department { get; set; }
}
@Html.DropDownList("DepartmentID", null, htmlAttributes: new { @class = "form-control" })
ViewBag.DepartmentID = new SelectList(db.Department, "DepartmentID", "DepartmentName");
return View();
}