Conditional Formatting of HyperLink on Datagrid

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!
 
C

chuckdfoster

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
 
S

Scott Allen

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top