Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change Grid Cell based on date

Status
Not open for further replies.

dvannoy

MIS
May 4, 2001
2,765
US
I trying to change a cell in my gridview based on a past due date. So anything that's greater then "Today" would get highlited. can't seem to get it to work. any help would be appreciated

Protected Sub dg1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)

Dim currDate As DateTime = Convert.ToDateTime(DateTime.Now.ToString("{0:d}"))

If e.Row.RowType = DataControlRowType.DataRow Then
If Convert.ToDateTime(DataBinder.Eval(e.Row.DataItem, "DUE_DATE").ToString()) < currDate Then
e.Row.Cells(0).BackColor = System.Drawing.Color.Yellow
End If
End If

End Sub

 
got it...

If e.Row.RowType = DataControlRowType.DataRow Then
If (e.Row.DataItem("DUE_DATE") <= Now()) Then
e.Row.ForeColor = Drawing.Color.White
e.Row.BackColor = Drawing.Color.Red
End If
End If

 
is your logic correct? in your original post you said "greater than"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top