title: How can i get DataGridView row values and store in variables?
body: <p>How can i loop through a DataGridView's rows at a time (I have 2 columns) then store those 2 columns in a variable which I will be using as a parameter for an sql query?</p>
  
  <pre><code>  foreach (DataGridViewRow Datarow in contentTable_grd.Rows)
              {
                  contentValue1 = Datarow.Cells[0].Value.ToString();
                  contentValue2 = Datarow.Cells[1].Value.ToString();
  
                  SqlParameter param4 = new SqlParameter("@contentTableValue1", contentValue1);
                  SqlParameter param5 = new SqlParameter("@contentTableValue2", contentValue2);
  
              }
  </code></pre>
  
  <p>I'm getting this error when using the above code -</p>
  
  <blockquote>
    <p>Object reference not set to an instance of an object.</p>
  </blockquote>