【发布时间】:2013-04-03 18:14:00
【问题描述】:
我在上面有一个显示原因和时间的网格视图。
我想做的是:
时间为
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;
//}
}
}
【问题讨论】: