Change datagrid cell properties using ASP.NET C#

public void dgBoundItems(object sender, DataGridItemEventArgs e) 
{ 
    foreach(TableCell cell in e.Item.Cells) 
    { 
        ///e.Item.DataSetIndex = row 
        ///e.Item.Cells.GetCellIndex(cell) = column
        if (e.Item.Cells.GetCellIndex(cell) == 2 && e.Item.DataSetIndex > 0) 
        {
            ///If the salary is less than 5000 the color must be red. 
            if (Convert.ToInt32(cell.Text.Trim()) < 5000) 
            { 
                cell.ForeColor = Color.Red; 
            } 
        } 
    } 
}