Hi MeghaPatel,
Refer the below link. You need to change the below code.
C#
private void button1_Click(object sender, EventArgs e)
{
foreach (DataGridViewRow row in dataGridView1.Rows)
{
int Id = Convert.ToInt32(row.Cells["id"].Value);
string City = Convert.ToString(row.Cells["City"].Value);
Update(Id, City);
row.DefaultCellStyle.BackColor = Color.Red;
}
}
VB.Net
Private Sub button1_Click(sender As Object, e As EventArgs)
For Each row As DataGridViewRow In dataGridView1.Rows
Dim Id As Integer = Convert.ToInt32(row.Cells("id").Value)
Dim City As String = Convert.ToString(row.Cells("City").Value)
Update(Id, City)
row.DefaultCellStyle.BackColor = Color.Red
Next
End Sub