/// <summary>
/// 格式化日期显示的颜色,当天为红色
/// </summary>
/// <param name="ModifyDate"></param>
/// <returns></returns>
public System.Drawing.Color GetTitleForColor(string ModifyDate)
{
if(DateTime.Parse(ModifyDate).Date.Equals(DateTime.Now.Date))
{
return Color.Red;
}
else if((DateTime.Parse(ModifyDate).AddDays(1).Date.Equals(DateTime.Now.Date)))
{
return Color.Orange;
}
else
{
return Color.Black;
}
}
/// 格式化日期显示的颜色,当天为红色
/// </summary>
/// <param name="ModifyDate"></param>
/// <returns></returns>
public System.Drawing.Color GetTitleForColor(string ModifyDate)
{
if(DateTime.Parse(ModifyDate).Date.Equals(DateTime.Now.Date))
{
return Color.Red;
}
else if((DateTime.Parse(ModifyDate).AddDays(1).Date.Equals(DateTime.Now.Date)))
{
return Color.Orange;
}
else
{
return Color.Black;
}
}
如果ModifyDate==“12“ DateTime.Now.Date也等于12
return Color.Red
如当日不是12号是13号
ModifyDate+1=DateTime.Now.Date
相当于12+1=13
return Color.Orange;
否则
return Color.Black;
.aspx的Label绑定
<asp:Label id=lblDate runat="server" ForeColor='<%# GetTitleForColor(DataBinder.Eval(Container, "DataItem.ModifyDate").ToString()) %>' Text='<%# "[" + DataBinder.Eval(Container, "DataItem.ModifyDate","{0:M-d}") + "]" %>'></asp:Label>