Conditional Formatting of HyperLink on Datagrid

  • Thread starter Thread starter chuckdfoster
  • Start date Start date
C

chuckdfoster

I have a hyperlink column in my datagrid. I want my hyperlink to be green
or red (depending on in/out status) no matter if the link has been visited
or not. How can I accomplish this? I have tried using CSS but that doesn't
affect what is going on in my datagrid. This is what I have so far for
formatting in my datagrid...

Sub ItemBound(ByVal sender As Object, ByVal e as DataGridItemEventArgs)
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
'check inout field, if In then font is green, if Out then font is
red
Dim strInOut as String = DataBinder.Eval(e.Item.DataItem, "inout")
If strInOut = "In" then
e.Item.ForeColor = System.Drawing.Color.Green
Else
e.Item.ForeColor = System.Drawing.Color.Red
End If
End If
End Sub

Any advice is greatly appreciated....Thanks in advance!
 
Scott, Thanks for the help, but that just confuses me more. All that does
is change the background color of the cells. I can do that; I just need to
change the color of the hyperlinks. Anymore help is greatly appreciated!

Thanks again!!!

Chuck Foster
 
Hi Chuck:

Sorry for the confusion. I only meant to point out some different
techniques to use when data binding - it doesn't show how to achieve
your particular task. Whenever it comes to putting some brains behind
the data binding, hooking an event and using code behind is the
generally accepted approach.
 
Back
Top