If cell color is depend on criteria
if (ca.con.State == ConnectionState.Closed)
{
ca.con.Open();
}
string qry = "select * From productmaster ";
SqlDataAdapter da = new SqlDataAdapter(qry, ca.con);
DataSet ds1 = new DataSet();
da.Fill(ds1, "productmaster");
for (int i = 0; i < ds1.Tables["productmaster"].Rows.Count; i++)
{
int val = Convert.ToInt32(dataGridView1.Rows[i].Cells[4].Value);
if (val == 0)
{
dataGridView1.Rows[i].Cells[4].Style.ForeColor = Color.Red;
}
else
{
dataGridView1.Rows[i].Cells[4].Style.ForeColor = Color.Green;
}
}