I have a model and that model has a public List<string> Hour { get; set; }
and the constructor
public SendToList()
{
Hour = new List<string> { "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23" };
}
My question is why don't I get a selected value for this
@Html.DropDownListFor(model => model.Hour, Model.Hour.Select(
x => new SelectListItem
{
Text = x,
Value = x,
Selected = DateTime.Now.Hour == Convert.ToInt32(x)
}
))
But I get a selected value here.
@Html.DropDownList("Model.Hour", Model.Hour.Select(
x => new SelectListItem
{
Text = x,
Value = x,
Selected = DateTime.Now.Hour == Convert.ToInt32(x)
}
))
What is the difference?