Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
945
Row Background color and selected row
posted

I was trying to set the background color on a row based on a certain condition. I managed to do this using the "e.Row.CssClass = HighlightColor;" in the InitializeRow event. In turn my CSS class was like the following..

                        tbody > tr.LightGreen > td

                        {

                            background-color:LightGreen !important;

                        }

The only problem with this is that the selected row color no longer gets applied to the grid as the setting of the cssClass at TR is taking precedence over the TD settings even thought the TD is getting the correct class. I  then tried an alternative approach which was to set the cssClass at the cell level. So my code was something like the following 

                    foreach (GridRecordItem CurrentCell in e.Row.Items)

                    {

                           CurrentCell.CssClass = HighlightColor;

                    }

and the following setting was in my CSS

                    tbody > tr > td.LightGreen

                    {

                    background-color:LightGreen !important;

                    }

The too sets the background color but i still do not get the selected record color appearing. What combination could i use to get the rowcolor to appear when the row is not selected and obviously the selected color to appear if the row is selected

Regards,

Ray