I have Dropdown list of Faculty Name. In my database they are stored as FirstName, LastName, MiddleName,
I want to combine it in dropdownlist
ViewData["FacultyID"] = new SelectList(faculty, "ID", "FirstName");
at place of datatextfield.
I have Dropdown list of Faculty Name. In my database they are stored as FirstName, LastName, MiddleName,
I want to combine it in dropdownlist
ViewData["FacultyID"] = new SelectList(faculty, "ID", "FirstName");
at place of datatextfield.
You could change your sql query:
SELECT ..., COALESCE(FirstName + ' ' + MiddleName + ' ' + LastName) as FullName,...
ViewData["FacultyID"] =
new SelectList(faculty.Select(f=> new
{id= f.Id, Name = f.Firstname + f.LastName}), "ID", "Name");