You error has nothing to do with colors and all that stuff. Error must be at first line of your code.That is:
int esal = int.Parse(e.Row.Cells[3].Text.ToString());
Replace this with below code:
int esal= string.IsNullOrEmpty(e.Row.Cells[3].Text) ? 0 : int.Parse(e.Row.Cells[3].Text);
Regards...