title: ADO.NET DataRow - check for column existence
body: <p>How do I check for the existence of a column in a datarow? </p>
  
  <p>I'm building datatables to organize some data that I've already pulled back from the database. Depending on the type of data in each row, I need to create a datatable with different columns.  Then, later on, I want to check and see if the datatable I am looking at has a certain column.</p>
  
  <p>I know I can catch the exception and handle it that way, but I'm curious if there is a property or method on the datarow object that will do this for me?</p>
  
  <p>Here's how I can do it by catching the exception:</p>
  
  <pre><code>public static String CheckEmptyDataRowItem(DataRow row, String rowName, String nullValue)
  {
      try
      {
          return row[rowName].ToString();
      }
      catch (System.ArgumentException)
      {
          return nullValue;
      }
  }
  </code></pre>