Hi,
I tried to follow this but the default modelbinder let my array null on the server side.
HTML:
Question 1:
<input name="list[0]" type="radio" value="1000" />No
<input name="list[0]" type="radio" value="1001" />Yes
Question 2:
<input name="list[1]" type="radio" value="1002" />No
...
Controller action:
public ActionResult Anamnesis(string[] list)
{
If I choose only the second "No" (list[0] is missing) then the DefaultModelBinder is impossible to transform it into an array.
Thanx in advance!
Update#1
Reformatted based on the comment, thank you!
Update#2
Just a tought: created a hidden input after all list item, and in this way it works. But it's ugly, no doubt.
Question 1:
<input name="list[0]" type="radio" value="1000" />No
<input name="list[0]" type="radio" value="1001" />Yes
<input type="hidden" name="list[0]"/>
Question 2:
<input name="list[1]" type="radio" value="1002" />No
<input type="hidden" name="list[1]"/>
...
Order it's very important: the hidden value submits only when the radio is unchecked. The idea it's from the ASP.NET MVC helpers. (Btw I cannot use Html.RadioButton to archive this behavior.)