I have this code below working fine.
Sample output
Computer Department
Technical Department
Product Department
Let say my department is Product Department
. I am the the who log-in in the system / project
. It is possible to first load my department in the DropDownList?. What I mean in first load is upon loading of the dropdown my department is set to be the first.
Controller
ViewBag.DepartmentId = new SelectList(db.Departments, "DepartmentId", "DepartmentDesc", null).OrderBy(m => m.Text);
HTML
@Html.DropDownList("DepartmentId ", ViewData["DepartmentId "] as SelectList, "", new { @style = "width:130px;" })