Asp.net-mvc – asp.net MVC checkbox headache!

asp.net-mvccheckbox

I have seen lots of questions relating to this topic.

I am using asp.net MVC 1.0

Problem area

If I use

<%= Html.CheckBox("Status", true) %>

Then why It renders like

<input checked="checked" id="Status" name="Status" type="checkbox" value="true" /><input name="Status" type="hidden" value="false" />

I put this in foreach loop and I have 5 rows.

when I submit form with true,true,true,false,false
then I get true,false,true,false,true,false,false,false

i.e. for false => false.

for true => true,false

If I use

<input type="checkbox" value="true" name="Status" checked="checked" />

Then I don't get unchecked one's.

so how do I overcome form this problem?

Please don't post answer with using loop in formcollection object and checking each key!

Best Answer

I know this isn't the elegant one but this is what I did:

collection["response"].Replace("true,false", "true").Split(',').ToList();