Change your query to include count of occurrence using
group by
, if possible.
Then you can directly use
RowDataBound
event
If (e.Row.DataItem("occurrence") > 1) Then
e.Row.BackColor = Drawing.Color.Red
End If
Otherwise, you need to loop through rows, and check whether it is duplicate or not and set the
BackColor
accordingly.