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

5 posts, 1 answers
  1. Beatrice
    Beatrice avatar
    10 posts
    Member since:
    Jun 2014

    Posted 05 Sep 2014 Link to this post

    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.
  2. Eyup
    Admin
    Eyup avatar
    4014 posts

    Posted 10 Sep 2014 Link to this post

    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.

     
  3. Beatrice
    Beatrice avatar
    10 posts
    Member since:
    Jun 2014

    Posted 14 Oct 2014 in reply to Eyup Link to this post

    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;
                }
            }
        }
  4. Answer
    Eyup
    Admin
    Eyup avatar
    4014 posts

    Posted 15 Oct 2014 Link to this post

    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.

     
  5. Beatrice
    Beatrice avatar
    10 posts
    Member since:
    Jun 2014

    Posted 15 Oct 2014 in reply to Eyup Link to this post

    Thank you Eyup! Got the answer from that forum.
    http://www.telerik.com/forums/how-to-change-row-color-in-radgridview
Back to Top