Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Oct 12, 2009 06:44 AM by KeFang Chen - MSFT
Oct 08, 2009 10:06 AM|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|LINK
Hi, try following-
GridView1.Rows.Cells.BackColor = System.Drawing.Color.Blue;
Oct 09, 2009 07:39 AM|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|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.