I have a datatable
that looks like this:
Row1 Row2 Row3 Row4 Row5 Row6
Gold Gold
Pink Pink
You can check the value of each cell in the RowDataBound
event and color the cell based on it's value.
protected void GridViewClicks_RowDataBound(object sender, GridViewRowEventArgs e)
{
//check if the current row is a datarow
if (e.Row.RowType == DataControlRowType.DataRow)
{
//loop all the cells in the row
foreach (TableCell cell in e.Row.Cells)
{
//check if the color is hex or a string
if (cell.Text.Contains("#"))
{
cell.BackColor = ColorTranslator.FromHtml(cell.Text);
}
else
{
cell.BackColor = Color.FromName(cell.Text);
}
}
}
}