I have a model that looks like this
public class ViewModel
{
public Dictionary<int, int[]> SelectedRoomIds
}
On my page I have something like this
@foreach(var floor in floors)
{
@Html.Hidden("SelectedRoomIds.Index", floor)
@Html.Hidden("SelectedRoomIds[" + floor + "].Key", floor)
@Html.ListBox("SelectedRoomIds[" + floor + "].Value", Model.FloorSelectList)
}
This works (binds) great if at least one item is selected in any of the list boxes, but it throws an exception that I can't seem to trap somewhere if nothing is selected. If nothing is selected I would expect either the key exists with a null int array or the entire dictionary be null. Neither is the case. Any suggestions are greatly appreciated.