I have no idea how to work this out but my drop down list code looks as follows:
in the action:
DateTime[] allSundaysInMonth = GetDatesOfSundays(System.DateTime.Now);
DateTime[] allSundaysInLastMonth = GetDatesOfSundays(System.DateTime.Now.AddDays(-30));
List<SelectListItem> listOfSundays = new List<SelectListItem>();
foreach (DateTime dt in allSundaysInThisMonth)
{
listOfSundays.Add(new SelectListItem
{
Text = dt.Name,
Value = dt.Id.ToString(),
Selected = dt.CompanyId == Id
});
return listOfSundays;
}
I need to take the last two sundays af last month and all sundays of this month, but not future sundays, and build a list with all these sundays.
This is something i did while on a past project
just modify your T so it will return what you need.