title: Adding DataRow[] data to each column in an unbound DataGridView?
body: <p>I am trying to query my DataSet and display the results in an unbound DataGridView. I feel like I am quite close with my programming logic here, but I keep getting the error <code>ArgumentOutOfRange Exception. Index was out of range. Must be non-negative and less than the size of the collection.</code></p>
  
  <p>My code snippet:</p>
  
  <pre><code>DataRow[] foundRows;
  
  //Queries the Reservations table with the 'searchExpression' variable
  foundRows = this.reservationMasterDataSet.Tables["Reservations"].Select(searchExpression);
  
  //If there is at least one record found...
  if (foundRows.Length &gt; 0)
  {
      //Used to count our row indexes
      int i = 0;
  
      //Populate the DataGridView with the queried response
      foreach (DataRow row in foundRows)
          {
              //Used to count our column indexes
              for (int j = 0; j &lt; reservationMasterDataSet.Tables["Reservations"].Columns.Count; j++)
              {
                  //THIS LINE IS THROWING AN EXCEPTION
                  dataGridView1.Rows[i].Cells[j].Value = row.ItemArray[j];        
              }
  
              i++;
          }
  }
  </code></pre>
  
  <p>My <code>DataRow</code> contains 12 objects so I made sure that the <code>DataGridView</code> has 12 columns to correspond (and there are 12 in the original database). I think I am getting the exception right away (<code>i</code> is still <code>0</code> in debugger). I first tried it using just <code>row[i]</code> but got the same error.</p>
  
  <p>This is meant to be a search results pane, not an editable thing, which is why I want to only return certain results. I figured the <code>DataGridView</code> is the nicest and easiest way to layout the record on a Windows form.</p>