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

To change the background color of row

1 Answer 80 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Angella
Top achievements
Rank 1
Angella asked on 19 Oct 2012, 04:37 AM
Hi,

In my RadGrid, I have  a column named 'colorCode'. I need to change the background color of row depending on the value of 'colorCode' say true or false in database. How can I do that?

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 19 Oct 2012, 04:42 AM
Hi,

Please try the following code snippet to give color for the row.

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

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