title: Validating DataGrid data when bound directly to a DataTable - C#/WPF
body: <p>I have a DataTable which I bind to a DataGrid in WPF. No column generation is done in the XAML, everything is done when I create the DataTable in code.</p>
  
  <p>I have 2 way binding, so the user can update the values in the DataGrid and it will update the DataTable, although this is not an event I can see when debugging, my results show it works as intended.</p>
  
  <p>However if the type of a column is say double and the user enters text, the existing DataTable data for that cell is preserved, the cell is outlined in red and my debugger output shows a FormatException occurred. </p>
  
  <p>What I am wanting to do is be able to either:</p>
  
  <p>a) Handle this exception and show a warning to the user in my UI</p>
  
  <p>b) Have some custom validation method which can set a flag in my code that I can use to handle the error at some point</p>
  
  <p>I don't mind which solution I go with, I just don't want the user to not notice the error.</p>
  
  <p>Thanks.</p>