我有一个显示原因和时间的gridview。
我想要做的是:
要显示红色时,时间是
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;
//}
}
}
它完美地工作。非常感谢。 – Apollo