int i = 0;
double a = 0;
string tmpProductID;
for (i = 0; i <= dataGridView1.Rows.Count - 1; i++)
{
tmpProductID = dataGridView1.Rows[i].Cells[1].Value.ToString();
if (tmpProductID ==Items )
{
a += Convert.ToDouble(dataGridView1.Rows[i].Cells[5].Value);
}
dataGridView1.Rows[i].Cells[1].Value = a.ToString("#,##0");
}