Link to home
Start Free TrialLog in
Avatar of David Pickart
David PickartFlag for United States of America

asked on

Change color of row based on bound YES/No column.

I have a YES/NO Field bound to a column in a gridview.  If that column is false, I would like to change color of row, otherwise leave as is.
SOLUTION
Avatar of TimCottee
TimCottee
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Swapnil
Swapnil
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of David Pickart

ASKER

I found another posting and came up with following that works when added to the "gvWorkweek2.RowDataBound" event.  

I also added a line ".Cells(0).Visible = False" that hides first column, which  has the edit and delete tags.  But when I do this the header text for the column is still there.  How can I hide that as well?  Here is my code.


With e.Row
            Dim rv As Data.DataRow
            If .RowType = DataControlRowType.DataRow Then
                rv = CType(.DataItem, Data.DataRowView).Row
                ' Change color
                If Not IsDBNull(rv("Approved")) Then
                    If rv("Approved") = "True" Then
                        .BackColor = Drawing.Color.Red
                        .Cells(0).Visible = False
                    Else

                    End If
                End If
            End If
        End With