c# - Issue with changing Gridview cell color depending on condition -


i trying change cell color of gridview, if dot < today's date. issue changes red rows dot column though dot column > today's date.
enter image description here

here code

 protected void onrowdatabound_gvtest(object sender, gridviewroweventargs e)         {            if (e.row.rowtype == datacontrolrowtype.datarow)           {              label lbldot = (label)e.row.findcontrol("dot");             datetime dotdate = datetime.parse(lbldot.text);             if (dotdate < datetime.now)             {               //e.row.backcolor = system.drawing.color.red;               gvdriverstatus.columns[3].itemstyle.forecolor = system.drawing.color.red;             }             }         } 

this:

gvdriverstatus.columns[3].itemstyle.forecolor = ... 

will change color of whole column. change cell color, use:

e.row.cells[3].forecolor = ... 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -