title: Error: 'Input string was not in a correct format.'
body: <pre><code>int sum = 0;
          for (int i = 0; i &lt; dataGridView1.Rows.Count;++i)
          {
              sum += Convert.ToInt32(dataGridView1.Rows[i].Cells[2].Value);
  
          }
  
          label1.Text = sum.ToString();
  </code></pre>
  
  <p>Above is the code to calculate.
  When I run the application it displays no errors. After I load the datagridview from MySql and press the button that leads to the above function it displays error.</p>
  
  <blockquote>
    <p>System.FormatException: 'Input string was not in a correct format.'</p>
  </blockquote>
  
  <pre><code>sum += Convert.ToInt32(dataGridView1.Rows[i].Cells[2].Value);
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/ifZfN.png" rel="nofollow noreferrer">Here is an example of the datagridview</a></p>
  
  <p>If I change Cells[2] to Cells[0] it works fine</p>
  
  <p>I am still a C# beginner, but Im guessing it is unable to convert the data in 'earned' column to integers?</p>