Last post Oct 12, 2009 06:44 AM by KeFang Chen - MSFT
Oct 08, 2009 10:06 AM|Salvatore Di Fazio|LINK
I would like to change the color in a cell when the record I had rendered match a condition.
How can I do that?
Oct 09, 2009 07:29 AM|leena.d.patil|LINK
Hi, try following-
GridView1.Rows.Cells.BackColor = System.Drawing.Color.Blue;
Oct 09, 2009 07:39 AM|karnanaspnetforum|LINK
In RowCreated or RowDatabound
Try something like this
if (e.Row.RowType == DataControlRowType.DataRow)
int intsomeitem= (int)DataBinder.Eval(e.Row.DataItem, "someitem");
if (intsomeitem== 0)
e.Row.BackColor = System.Drawing.Color.LightPink;
e.Row.ForeColor = System.Drawing.Color.Maroon;
else if (intsomeitem== 1)
e.Row.BackColor = System.Drawing.Color.LightCyan;
e.Row.ForeColor = System.Drawing.Color.DarkBlue;
e.Row.BackColor = System.Drawing.Color.LightGray;
e.Row.ForeColor = System.Drawing.Color.Red;
Oct 12, 2009 06:44 AM|KeFang Chen - MSFT|LINK
Is the Html.Grid() customized by yourselv? If it is, you can customize the style for it according to your requirement.
Or else you have to check the grid to see whether some functions or propertys are supplied to change the style of one cell. If no one exists, maybe we can't do it.