I have an object:
class Milk {
public DateTime ExpirationDate {get;set;}
...
}
In a collection in a model:
class GroceryModel {
public IList<Milk> Milks {get;set;}
public Milk SelectedMilk {get;set;}
}
And I’m populating a dropdown list using Razor:
@Html.DropDownListFor(m => m.ExpirationDate, Model.Milks, ...);
How can I format the dates that appear in that dropdown list?
in your controller:
model.SelectMilk will hold a list of SelectListItems