以下のようにforeachすると、それぞれのrow/cellがobject型になってしまいます。
foreach(var row in dataGridView1.Rows){} //rowはobject型
foreach(var cell in this.dataGridView1.Rows[1].Cells) {} //cellはobject型
そこで、Cast<>()メソッドを使用して以下のようにすれば、うまくいく。
foreach(var row in dataGridView1.Rows.Cast<DataGridViewRow>()) {
foreach(var cell in row.Cells.Cast<DataGridViewCell>()) {
}
}