I have two DropDownListFor to list schedules (start time and end time), fill in the two lists with a SelectList that has a list of mounted schedules:
<span>Horario de incio</span>
@Html.DropDownListFor(m => m.HorarioInicial, Model.HorariosDisponiveisCadastro.Where(h => h <= new DateTime(1900, 01, 01, 12, 00, 00))
.Select(s => new SelectListItem() { Value = s.ToString("HH:mm"), Text = s.ToString("HH:mm") }), new { @class = "form-control", onchange = "changeHoraFim(this);" })
<br />
<span>Horario de fim</span>
@Html.DropDownListFor(m => m.HorarioFinal, Model.HorariosDisponiveisCadastro.Where(a => a > Convert.ToDateTime(Model.HorarioInicial))
.Select(s => new SelectListItem() { Value = s.ToString("HH:mm"), Text = s.ToString("HH:mm") }), new { @class = "form-control" })
I want you to select an initial time, DropDown of the end date only lists dates that are less than the start date
For example, if the user selects that the start time is 10:00 the other dropdown should list only hours after that (10:30, 11:00, 11:30 ...)