Imagine this formular. (I edited the form, to show what I am trying to do.)
@using (Html.BeginForm("Add", "Notify", FormMethod.Post ))
{
@foreach (KeyValuePair<Server, Services[]> server in ViewBag.ServerServices)
{
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="[email protected]">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#@server.Key.ServerID" aria-expanded="false" aria-controls="@server.Key.ServerID">
@server.Key.Servername
</a>
</h4>
</div>
<div id="@server.Key.ServerID" class="panel-collapse collapse" role="tabpanel" aria-labelledby="[email protected]">
@foreach (Services service in server.Value)
{
<input class="form-control" type="checkbox" name="selectedServerServices[@server.Key.ServerID]" value="@service.ServiceID"/><label>@service.ServiceName</label>
<br/>
}
</div>
</div>
}
I would like to get the posted values and the keys too, but I always get a null object when trying to retrieve both.
In Request.AllKeys I can see that there are two values (e.g.) But the posted values do not get into the defined dictionary
My Action method looks like this.
public ActionResult Add(Dictionary<string, int> test )