title: How do you clear a cell (so it gets NULL value) in (WPF) DataGrid?
body: <p>We have a column bound to a sql integer value that is nullable. When the user tries to "clear" the cell in the <code>DataGrid</code>, we get the validation error  </p>
  
  <blockquote>
    <p>"...could not be converted". </p>
  </blockquote>
  
  <p>How can I make it empty and bind a "null" value to the underlying column?</p>
  
  <p>I have googled this problem for 2 days now and found anything. I tried to edit my comment to you HCL, but it would never save.</p>
  
  <p>I am familiar with the <code>IValueConverters</code>. I wrote one to handle our percentages (so the user can enter "50 %" and it gets converted to ".5"). I am trying to do something very similar, but when the value comes back as a <code>Null</code> (I wrote a dummy <code>IValueConterter</code> to debug it), I just want it to be saved to the database as a <code>Null</code>. Maybe I just need to set it to <code>DBNullValue</code>? It just seems like a lot of work for something that I think might have a built in property. I tried using the <code>TargetNullValue</code> property on the column (<code>DataGridBoundColumn</code>) and setting that to <code>DBNull.Value</code>, but it didn't change the value (based on my dummy <code>IValueConverter</code> it is still coming in as a regular (string) <code>NULL</code>. </p>
  
  <p>I simply want to be able to save a null value to the database for this (integer type) column.</p>
  
  <p>** Latest addition **</p>
  
  <p>Good point HCL, I forget that the whole world isn't ADO sometimes. </p>
  
  <p>I am binding to a SQL table. The column in question is an <code>int</code> that allows <code>NULL</code>s.</p>
  
  <p>The columns are created using <code>AutoGeneratingColumn</code>, so it basically just hooks them up "automagically" (certain styles such as Right Justify are applied in this method, but not for this column). It takes this approach, because the app is pretty much an "Access" replacement. Our CIO mandated we remove Access from the users, so this was the solution (create our own MS Access). Anyway, since it can open any table (and create tables, columns, etc) it just "AutoGenerates" the columns based on the table that was opened. Although, since there are certain columns that the app inherently knows about such as Discount_Pct, when it encounters one of those columns, it does do some "special stuff" (like assign the <code>IValueConverter</code> I described above). Although, like I said... for this particular column, there isn't anything "special" done to it. It is just a regular SQL integer (nullable) that is "AutoGenerated".</p>