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

[Solved] How do i color rows in a grid

2 Answers 141 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 14 Jul 2009, 09:23 AM
How do i change the colour of a row in a grid depending on a variable from the results comming in from a datasource

Many thanks

Kevin

2 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 14 Jul 2009, 09:44 AM
Hello Kevin,

Please examine the following link:
Conditional Formatting for rows/cells on ItemDataBound

I hope this helps.

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Princy
Top achievements
Rank 2
answered on 14 Jul 2009, 09:51 AM
Hello Kevin,

Here's an example of how this can be done:
c#:
 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem dataItem = (GridDataItem)e.Item; 
            foreach (GridColumn col in RadGrid1.MasterTableView.RenderColumns)            
            { 
                if (dataItem[col.UniqueName].Text == "text"
                { 
                    dataItem.BackColor = System.Drawing.Color.Red; 
                } 
            } 
        } 
    } 

Also check out the following help document which explains on how to set a background color for a row based on a condition:
Conditional Formatting for rows/cells on ItemDataBound

Thanks
Princy.
Tags
Grid
Asked by
Kevin
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Princy
Top achievements
Rank 2
Share this question
or