如果日期之间的条件 [英] If Conditions between dates
问题描述
i有列表与EXPIRY日期:
我的表条件是:
如果到期日< 30天然后我在gridview Cell空格中显示列
如果到期日期< = 5天然后我在gridview中显示列单元格backcolor'blue',日期
如果到期日期< = 3天然后我在gridview中显示列单元格backcolor'黄色'带日期
如果到期日期< = 1天,那么我在gridview中显示该列单元格背景颜色'红色'与日期
========= ==============================================
如何为此编写代码?
i have table of column with EXPIRY Dates:
My Table Conditions are :
if expiry date < 30 days then i show the column in gridview Cell Empty
if expiry date <= 5 days then i show the column in gridview Cell backcolor 'blue' with date
if expiry date <= 3 days then i show the column in gridview Cell backcolor 'yellow' with date
if expiry date <= 1 days then i show the column in gridview Cell backcolor 'Red' with date
=======================================================
How can i write code for this ?
推荐答案
http://forums.asp.net/t/1352196.aspx/1 [ ^ ]
u可以检查链接..请参阅if- else-if statement..hope它会帮助..
http://forums.asp.net/t/1352196.aspx/1[^]
u can check the link..refer the if-else-if statement..hope it will help..
In RowDataBound event, add the below code
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (your condition goes here for 30)
e.Row.Cells[1].Text = "";
else if (your condition goes here for 5)
e.Row.Cells[1].BackColor = Color.Blue;
else if (your condition goes here for 3)
e.Row.Cells[1].BackColor = Color.Yellow;
else if (your condition goes here for 1)
e.Row.Cells[1].BackColor = Color.Red;
}
Cells [到期日期栏索引]
希望这能帮到你
Cells["index of expiry date column"]
Hope this will help you
这篇关于如果日期之间的条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!