Gridview Conditional Formatting ?

E

euan

HI Guys,

I have bee using conditional formatting in the datagrid recently and I
am moving over to framework 2.0 and noticed the datagrid has been
replaced by the gridview. So, I would like to do conditional formatting
on the gridview but it doesnt have the same methods.

Currently in my datagrid I have this (this is just hacked together
randomly but gives you the idea):

Sub ItemDataBoundEventHandler(ByVal sender As Object, ByVal e As _
DataGridItemEventArgs)
Dim m As String = DataBinder.Eval(e.Item.DataItem, "name")
If Trim(m) = "Euan" Then
e.Item.Cells(1).BackColor = System.Drawing.Color.Yellow
e.Item.Cells(1).Text = e.Item.Cells(1).Text & "*"
End If
End Sub

But I would like to achieve something like that in gridview.

Further to that (if anyone knows), does anyone know how I could
intelligently detect the column number of the column "name" in
gridview?

This may seem like a stupid question but I am reasonably new to asp.net

Regards,
Euan
 
Joined
Oct 29, 2007
Messages
1
Reaction score
0
You could do something as simple as this:

Sub RowDataBoundEvent(o as object, e as GridViewRowEventArgs) Handles MyGridView.RowDataBound
If Trim(e.Row.Cells(1).Text) = "Euan" Then
e.Row.Cells(1).BackColor = Drawing.Color.Yellow
End If
End Sub

This would check if the second column = Euan and make it yellow if it is.
 

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

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top