@ Html.ListBoxFor is used for your strong typed viewmodel. which can help link your property. The first part will take the lambda expression for an individual element as the default value for your list, the second part will take a collection of elements to display all the elements in the list. For example: you have the following two classes.
public class HospitalViewModel
{
public string SelectedPatient { get; set; }
public IEnumerable<Patient> AllPatients { get; set; }
}
public class Patient
{
public int Id { get; set; }
public string FirstName { get; set; }
}
From your view, you should do something like
@model HospitalViewModel
@Html.ListBoxFor(model => model.SelectedPatient, new SelectList(Model.AllPatients,"Id", "FirstName"));
, , Html.ListBox
@model IEnumerable<Patient>
@Html.ListBox("ListBoxName", new SelectList(Model,"Id", "FirstName"));