我上面有一个显示原因和时间的网格视图。
我想做的是:
时间到时显示红色
BETWEEN 12:00:00 PM and 12:59:59 PM AND is Beginning of Day
时间到时显示绿色
BETWEEN 13:00:00 PM and 13:59:59 PM AND is LUNCH
我让它为列 REASON 工作。
下面是我的代码。注意:e.Row.Cells[4] 用于列原因,e.Row.Cells[5] 用于列时间
protected void GridViewEmployee_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//Works
if (e.Row.Cells[4].Text == "Break")
{
e.Row.Cells[4].BackColor = Color.Red;
}
//Doesn't Work
//if (e.Row.Cells[4].Text == "Beginning Of Day" && e.Row.Cells[5].Text > " 12:00:00 PM " && e.Row.Cells[5].Text < "12:59:59 PM")
//{
// e.Row.Cells[4].BackColor = Color.Red;
//}
}
}