title: Bind checkbox on DB initial null value
body: <p>I need to bind a checkBox but with this line of code,</p>
  
  <pre><code>&lt;asp:CheckBox ID="CheckBoxRed" runat="server"  Checked='&lt;%# Bind("red") %&gt;'/&gt;
  </code></pre>
  
  <p>because initially the value in the DB is null, I get an invalid cast. I therefore tried in this way:</p>
  
  <pre><code> &lt;asp:CheckBox ID="CheckBoxRed" runat="server"  Checked='&lt;%# (DataBinder.Eval(Container.DataItem,"red") is DBNull ?false:Eval("red")) %&gt;'/&gt;
  </code></pre>
  
  <p>This avoids the initial invalid cast but if I check the checkbox the value is not saved to the db.
  Is there a way to avoid the initial invalid cast and get the checked/unchecked status saved into the db?</p>
  
  <p>I already checked <a href="https://stackoverflow.com/questions/21980312/checkbox-bind-even-if-null-datatable-control">this</a> answer but it does not bind the value.</p>