【发布时间】:2015-09-28 19:15:54
【问题描述】:
我想显示如果续订日期列日期大于今天的日期,那么它应该以背景颜色 = 红色突出显示。这里我没有得到单元格 7 中的值。该值在更新日期 col - 15-02-2014
<asp:TemplateField HeaderText="Renewal Date" >
<ItemTemplate>
<a href='ChangeRenewaldate.aspx?Linkid=<%#Eval ("LinkId")%>'>
<asp:Label ID="lblRenewal" runat="server" Text='<%# Eval("RenewalDate","{0:dd-MM-yyyy}") %>'></asp:Label> </ItemTemplate>
</asp:TemplateField>
protected void GrdV_Projects_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (!string.IsNullOrEmpty(e.Row.Cells[7].Text))
{
if (e.Row.Cells[7].Text > DateTime.Now.ToString())
{
e.Row.Cells[7].BackColor = System.Drawing.Color.Red;
}
else
{
e.Row.Cells[7].BackColor = System.Drawing.Color.Green;
}
}
}
}
【问题讨论】: