I have a dropdownlistfor which lists selectable dates. I want to pre-select a certain date but even though it's marked as "Selected" it doesn't show as the selected when looking at the dropdownlist.
<%=Html.DropDownListFor(model => model.SelectDropOfDate, Model.DropOffDates, new { id = "dropOfDate" })%>
In one thread that I read they said that "model.SelectDropOfDate" (in this case) is the selected item and if that's the case, should I select the value or the text in order for it to match the one in the list?
(the list of dates).Where(x=>x.Selected).Select(z=>z.Value).ToString();
(Ps: I've tried both value and text and none of them worked)
Any ideas?
getDropOffDates
returns the model to the view where yourDropDownListFor
is? Because if it is then it means your model is a collection and doingModel.DropOffDates
is not right? – von v.