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

[Solved] Change row color based on cell value

1 Answer 328 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Allen
Top achievements
Rank 1
Allen asked on 17 Jul 2013, 12:38 PM
Hi
How can I change the color of a row depending on the value of a cell in the row. Somebody please help me out.
thanks
Allen

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 17 Jul 2013, 12:40 PM
Hi,

Please try the code to change the color for the row.

C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem item = (GridDataItem)e.Item;
        if (item["UniqueName"].Text == "Your Text")
        {
            item.BackColor = System.Drawing.Color.Red;
        }
        else
        {
            item.BackColor = System.Drawing.Color.Green;
        }
    }
}

Thanks,
Princy.
Tags
Grid
Asked by
Allen
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or