Tutorial :How to combine columns for DatatextFiled of DropdownList?


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.


ViewData["FacultyID"] =      new SelectList(faculty.Select(f=> new      {id= f.Id, Name = f.Firstname + f.LastName}), "ID", "Name");  


You could change your sql query:

SELECT ..., COALESCE(FirstName + ' ' + MiddleName + ' ' + LastName) as FullName,...  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »