title: c# DataColumn: generate a new GUID as default value?
body: <p><strong>My problem:</strong><br>
  I have a <code>DataSet</code> with multiple <code>DataTables</code> in it.
  All of these <code>DataTables</code> have a <code>DataColumn</code> named "Id" with a <code>DataType</code> of <code>System.Guid</code>.</p>
  
  <p>A short example of such a table:</p>
  
  <pre><code>+--------------------+
  | User               |
  +--------------------+
  | *Id as System.Guid |
  | Username as String |
  | /* more columns */ |
  +--------------------+
  </code></pre>
  
  <p>I assigned this <code>DataTable</code> to a <code>DataGridView</code>. The <code>DataGridView</code> is configured to allow creating, editing and deletion of entries.</p>
  
  <p>When a user now creates a new entry and saves it, there is an exception that the "Id" is unset.</p>
  
  <p><strong>My question:</strong><br><em>How is it possible to automatically generate a new <code>System.Guid</code> for new entries?</em></p>
  
  <p><strong>My current thoughts:</strong></p>
  
  <ul>
  <li>Specifying some magic value in <code>dataSet.dataTable.Columns['Id'].DefaulValue</code> . (Something like the <code>&lt;DBNull&gt;</code>)</li>
  <li>Using something like a trigger on <code>dataSet.dataTable</code> listening for new rows. It would have to get executed <strong>before</strong> the row gets validated</li>
  <li>Same thing like the trigger, but on the <code>dataGridView</code>.</li>
  </ul>
  
  <p><strong>What I've tried:</strong></p>
  
  <ul>
  <li>These events of the <code>DataGridView</code>: <code>RowsAdded</code>, <code>UserAddedRow</code>, <code>RowValidating</code>, <code>DefaultValuesNeeded</code></li>
  </ul>
  
  <p>It would be awesome if anyone would have a working solution or a hint for me!</p>
  
  <p>~Chris</p>