chang this as
if (e.Row.RowType == DataControlRowType.DataRow && e.Row.RowState != DataControlRowState.Edit)
{
Label lblSalary = (Label)e.Row.FindControl("lblSalary");
decimal Sal = 0;
if(lblSalary!=null)
{
Sal = Convert.ToDecimal(lblSalary.Text);
}
else
{
TextBox txtSalary = (TextBox)e.Row.FindControl("txtSalary");
Sal=Convert.ToDecimal(txtSalary.Text);
}
if (Sal > 15000)
{
e.Row.Cells[2].ForeColor = System.Drawing.Color.Red;
}
}
or you can use
gridview1.editrowindex>=0
--Pankaj