Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Change Grid Cell based on date

Change Grid Cell based on date

Change Grid Cell based on date

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

RE: Change Grid Cell based on date

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

RE: Change Grid Cell based on date

is your logic correct? in your original post you said "greater than"

RE: Change Grid Cell based on date

sorry that was a typo...thanks

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close