i can view anybody record and then can edit it if i click edit button below record, after clicking it takes you to another page whihc shows textboxes and dropdown, checkboxes to edit and all textboxes contains values for that EmpID but problem is that i want pre selected value in DROPDOWN LIST, like it should pick corresponding value for each user a preselected like my textboxes. I am using LINQ TO SQL, MVC 3, asp.net C#
Controller:
var DepNames = (from n in DataContext.HrDepts select new { n.DeptID, n.DeptName }).Distinct();
ViewData["DeptName"] = new SelectList(DepNames, "DeptID", "DeptName", EmployeeValues.FirstOrDefault().DeptName);
View:
@using EmployeeAttendance_app.Models
@model IEnumerable<GetEmployeeEditDetails_SpResult>
@{
var Item = Model.FirstOrDefault();
}
@Html.DropDownList("DeptID", (SelectList)ViewData["DeptName"])