I'm trying to pass Collection of DateTime from my View:
@Html.ActionLink("Hello", "Index", "Home", new { dates = new Collection(){date1, date2)} })
Here is my action:
[HttpGet]
public ActionResult Index(int? page, string searchString, ICollection<DateTime> dates)
{ ...
But i always get null in dates. Any suggestions?
Update
The problem is as i think it creates incorrect url:
http://localhost:39152/Home?dates=System.Collections.ObjectModel.Collection%601%5BSystem.DateTime%5D
Btw i added:
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
{
var value = bindingContext.ValueProvider.GetValue(bindingContext.ModelName);
var date = value.ConvertTo(typeof (DateTime), CultureInfo.CurrentCulture);
return date;
}
And to action:
[HttpGet]
public ActionResult Index(int? page, string searchString, [ModelBinder(typeof (ModelBinders.DateTimeBinder))] ICollection<DateTime> dates)
{ ...