title: Rendering Nullable Bool as CheckBox
body: <p>I'm new from WebForms to MVC. I have view model field with the type <code>bool?</code> and, by default, <code>EditorFor()</code> renders this field as a DropDownList with a "Not Set" option. I would prefer to render it as a CheckBox and, if the value is null, just set it to unchecked.</p>
  
  <p>The field name is <code>RFP.DatesFlexible</code> and so I wrote the following markup in my view:</p>
  
  <pre><code>&lt;input type="checkbox" id="RFP_DatesFlexible" name="RFP.DatesFlexible" /&gt;
  &lt;label for="RFP_DatesFlexible"&gt;My Dates are Flexible&lt;/label&gt;
  </code></pre>
  
  <p>But this doesn't work. The result is always null and <code>ModelState.IsValid</code> is false.</p>
  
  <p>Can anyone say how I could make this work?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>This is the code I ended up with, which appears to work fine.</p>
  
  <pre><code>@Html.CheckBox("RFP.DatesFlexible", Model.RFP.DatesFlexible ?? false)
  @Html.Label("RFP.DatesFlexible", "My Dates are Flexible")
  </code></pre>
  
  <p>The label is correctly associated with the checkbox so that clicking the text will toggle the checkbox.</p>