Question Highlight GridViewRow UNLESS selected

VentureFree

Well-known member
Joined
Jan 9, 2008
Messages
54
Programming Experience
5-10
I've got a GridView whose SelectedRow is colored LightSkyBlue. I'm also highlighting some rows in the GridView Aqua based on some values in the data (please ignore the garish colors...not my choice). I'm doing this through the RowDataBound event with the following line of code:
VB.NET:
            If (CInt(MyGridView.DataKeys(e.Row.RowIndex)(1)) > 1) Then e.Row.BackColor = Drawing.Color.Aqua
The problem is that the highlight color takes precedence over the selection color, and I need it to be the other way around. In other words, I need to be highlighted in Aqua UNLESS it's selected, in which case it stays LightSkyBlue. Apparently, in the RowDataBound event MyGridView.SelectedIndex = -1, even if something is selected, so simply testing to see if it's selected doesn't work.

Is there perhaps some later event at which I can set the selected rows color explicitly, thereby overwriting the highlight? If not, exactly how might I go about highlighting a row UNLESS it's selected? Thanks.
 
Back
Top