title: DataColumn Name from DataRow (not DataTable)
body: <p>I need to iterate the columnname and column datatype from a specific row. All of the examples I have seen have iterated an entire datatable. I want to pass a single row to a function to do a bunch of conditional processing. I want to separate the conditional processing for ease of readability.</p>
  
  <p>This is what I have:</p>
  
  <pre><code>private void doMore(DataRow dr)
  {
      foreach (DataColumn c in dr.ItemArray)  //loop through the columns. 
      {
          MessageBox.Show(c.ColumnName.ToString());
      }
  }
  </code></pre>
  
  <p>The error returned is </p>
  
  <blockquote>
    <p>System.InvalidCastException: Unable to cast object of type 'System.String' to type 'System.Data.DataColumn'. </p>
  </blockquote>
  
  <p>How would I get the column name from the row or do I have no choice and must pass the entire datatable to the function?</p>