In my asp.net+vb weg in a gridview i am using this code for the month is less than this month
If e.Row.DataItem("Complete").Month < Now().Month AndAlso e.Row.DataItem("Complete").YEAR = Now().Year Then
e.Row.BackColor = Drawing.Color.LightCoral
i want to add two more row same as this code for
date (Complete) less than 1 current date
date (Complete) less than 2 current date
How about something like this:
Dim d As Date = e.Row.DataItem("Complete")
Select Case DateDiff("m", Date.Now, d)
Case 0
e.Row.BackColor = Drawing.Color.Red
Case -1
e.Row.BackColor = Drawing.Color.Green
Case -2
e.Row.BackColor = Drawing.Color.Blue
Case Else
e.Row.BackColor = Drawing.Color.LightCoral
End Select
this code works for month only i want the date part
What exactly do you mean by 'date(Complete) less than 1 current date' ?
I made a little changes from
DateDiff("m", Date.Now, d)
to
DateDiff("d", Date.Now, d)
and that was my requirement
thanks
沒有留言:
張貼留言