Reputation: 3751
I am populating the GridView from code-behind. The Due Date
(Format: mm-dd-yyyy
) is displayed for each row entry.
How can I modify the above so I can add the following: <asp:BoundField HeaderStyle-Width="1%" HeaderText="" ItemStyle-CssClass="taskTableColumn" />
(another column) between asp:TemplateField
and asp:HyperLinkField
where it will see if today is past the due date from the Due Date
column. If it is past the due date, set the background to #C000000
of that columns for that row.
Upvotes: 0
Views: 680
Reputation: 927
You can try this, definitely you need to change conditions
protected void RowDataBound(Object sender, GridViewRowEventArgs e)
{
//Check if it is not header or footer row
if(e.Row.RowType == DataControlRowType.DataRow)
{
if(e.Row.RowIndex == 0)
e.Row.Cells[0].BackColor = Color.Red;
if(e.Row.RowIndex == 1)
e.Row.Cells[0].BackColor = Color.Green;
}
}
Upvotes: 1