@stephen: thanks for the help. with keeping your answer in my mind I finally succeeded returning those data.
I changed the foreach into a for and changed ICollection to a List
Model:
using System;
using System.Collections.Generic;
using ProjectII.Models.domain;
namespace ProjectII.Viewmodels
{
public class DataModel
{
public List<DatumModel> Datums { get; set; }
public List<ToekomstModel> Toekomst{ get; set; }
}
public class DatumModel
{
public DatumModel()
{
Dag = new Opleidingdag(new DateTime().Date);
Checked = true;
}
public DatumModel(Opleidingdag opldag)
{
Dag = opldag;
Checked = true;
}
public Opleidingdag Dag { get; set; }
public bool Checked { get; set; }
}
public class ToekomstModel
{
public ToekomstModel()
{
Dag = new Opleidingdag(new DateTime().Date);
}
public ToekomstModel(Opleidingdag opldag)
{
Dag = opldag;
}
public Opleidingdag Dag { get; set; }
}
}
view:
@model ProjectII.Viewmodels.DataModel
@using(@Html.BeginForm())
{
<div>
<table>
<tr>
<th colspan="2">reeds begonnen dagen</th>
</tr>
@for (int i = 0; i < Model.Datums.Count; i++)
{
<tr>
<td>@Html.DisplayFor(modelItem => Model.Datums[i].Dag.Dag.Day)/@Html.DisplayFor(modelItem => Model.Datums[i].Dag.Dag.Month)/@Html.DisplayFor(modelItem => Model.Datums[i].Dag.Dag.Year)</td>
<td>
@Html.EditorFor(modelItem => Model.Datums[i].Checked)
</td>
</tr>
}
</table>
@*@for (int i = 0; i < Model.Datums.Count; i++)
{
<div> @Html.DisplayFor(x => Model.Datums[i].Dag.Dag)
@Html.CheckBoxFor(x => Model.Datums[i].Checked) </div>
}*@
</div>
<div id="toekomst">
<table>
<tr>
<th>Dagen in de toekomst</th>
</tr>
@foreach (var item in @Model.Toekomst)
{
<tr>
<td>@Html.DisplayFor(modelItem => item.Dag.Dag.Day)/@Html.DisplayFor(modelItem => item.Dag.Dag.Month)/@Html.DisplayFor(modelItem => item.Dag.Dag.Year)</td>
</tr>
}
</table>
</div>
<div>
<p><input type="submit" value="Volgende"/></p>
</div>
}
Now I recieve a model with the right values
thanks for the help people