protected void grdA_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Decimal Val= GetCellValue(5, e);
if (Val!= null)
{
if (Val< 0)
{
ColorThisCellBackColor(5, e, Color.FromArgb(255, 235, 214)); }
}
}
}
private void ColorThisCellBackColor(int ColumnIndex, GridViewRowEventArgs e, Color ColorName)
{
e.Row.Cells[ColumnIndex].BackColor = ColorName;
}
private Decimal GetCellValue(int ColumnIndex, GridViewRowEventArgs e)
{
try
{
Decimal cellval;
if (HttpUtility.HtmlDecode(e.Row.Cells[ColumnIndex].Text).Trim() == string.Empty)
{
cellval = 0;
}
else
{
cellval = Convert.ToDecimal(HttpUtility.HtmlDecode(e.Row.Cells[ColumnIndex].Text).Trim());
}
return cellval;
}
catch (Exception)
{
throw;
}
}