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

How to change backcolor of the row in Radgrid based on a column value?

4 Answers 752 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Beatrice
Top achievements
Rank 1
Beatrice asked on 05 Sep 2014, 06:42 PM
Based on a column value, I want to change the backcolor of the row in the Radgrid. How do we do it?

There are examples in "Conditional Formatting for rows/cells on ItemDataBound". But when I went to my code, I could not see "ItemdataBound" event for my RadGrid. So how to I change the row color based on a column value?

I populate my grid with the data table.

4 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 10 Sep 2014, 01:13 PM
Hi Beatrice,

I've created a sample RadGrid web site to demonstrate how you can achieve the requested functionality. Please run the attached application and let me know if it helps you.

Regards,
Eyup
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Beatrice
Top achievements
Rank 1
answered on 14 Oct 2014, 07:47 PM
Hi Eyup,

Attached is my screen shot of the events associated with the RadGrid. I do not see itemDataBound event. How do I get that event?

This was your code:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = e.Item as GridDataItem;
            int value = (int)double.Parse(item["Freight"].Text);            if (value % 2 == 0)
            {
                item["Freight"].BackColor = Color.Lime;
            }
            else if (value % 3 == 0)
            {
                item.BackColor = Color.LightBlue;
            }
        }
    }
0
Accepted
Eyup
Telerik team
answered on 15 Oct 2014, 05:40 AM
Hello Beatrice,

Do you use RadGrid for ASP.NET AJAX or RadGridView for WinForms?
http://www.telerik.com/products/winforms/gridview.aspx

In case of the latter, please open a new support ticket or forum thread choosing the corresponding option from the Product combo and the team responsible for the technology will reply to your query accordingly.

Regards,
Eyup
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Beatrice
Top achievements
Rank 1
answered on 15 Oct 2014, 06:45 PM
Thank you Eyup! Got the answer from that forum.
http://www.telerik.com/forums/how-to-change-row-color-in-radgridview
Tags
Grid
Asked by
Beatrice
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Beatrice
Top achievements
Rank 1
Share this question
or