0
我想顯示續訂日期列日期是否大於今天的日期,那麼它應該用背景顏色=紅色突出顯示。在這裏我不是在小區7所獲得的價值值在續約日期山坳 - 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;
}
}
}
}