This is a migrated thread and some comments may be shown as answers.

Change the background of rows that matches a condition

1 Answer 71 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Danilo
Top achievements
Rank 1
Danilo asked on 25 Feb 2016, 04:00 PM

Hello! I've been trying to highlight some rows in my grid that that indicates the start of a group of elements.
Problem is, when i use the RowLoaded event, it works right, changing the row i need but also changing other rows of the grid, that doesn't match the condition.

I want to change the background color in the rows where a string property is null or empty.

Is there any better way to approach it?

private void GridPer_RowLoaded(object sender, RowLoadedEventArgs e)
        {
            if (e.DataElement != null && string.IsNullOrEmpty(((e.DataElement as ClassifPeriods).Classificacao.CodMae)))
                e.Row.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#CC0000"));
        }

1 Answer, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 26 Feb 2016, 08:19 AM
Hello Danilo,

The recommended approach is to use a RowStyleSelector as demonstrated in this help article.

Regards,
Yoan
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
GridView
Asked by
Danilo
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Share this question
or