I have a gridview with column named "Maturity Date". We need to send warning and error notification based on the "maturity Date". Conditions applied to determine Warning and error is below
a) warning = a week away from the Maturity Date and equal to Maturity Date
b) error = past the Maturity Date
My code condition is always returning true.
` Protected Sub DG_Importer_OnRowDataBound(ByVal sender As System.Object, ByVal e As GridViewRowEventArgs) Handles DG_Importer.RowDataBound
Dim MaturityDate As String = DirectCast(e.Row.DataItem, System.Data.DataRowView).Row.ItemArray(3).ToString
Dim MD As DateTime = Convert.ToDateTime(MaturityDate)
Dim weekAwayDate As DateTime = MD.AddDays(-6)
Dim datepassed As DateTime = MD.AddDays(+1)
If datepassed > MD Then
cell.BackColor = Drawing.Color.MistyRose
cell.FindControl("error").Visible = True
Else If (weekAwayDate < MD) Then
cell.BackColor = Drawing.Color.LightYellow
cell.FindControl("warning").Visible = True
End If
End Sub