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

Set text color of individual rows programatically

2 Answers 49 Views
Grid
This is a migrated thread and some comments may be shown as answers.
wdudek
Top achievements
Rank 1
wdudek asked on 10 Feb 2011, 09:46 PM
Based on the value of one of the columns in each row I need to change the text color (or background) in order to indicate what type of record this is. I'm guessing I can do this in item created or pre render but haven't been able to find any examples? Can someone point me in the right direction?

Thanks

Bill

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 11 Feb 2011, 05:53 AM
Hello,

Try the following code snippet in the ItemDataBound event to achieve you scenario.

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
 {
      GridDataItem item = (GridDataItem)e.Item;
      if (item["ColumnUniqueName"].Text == "1")//checking for the column value.
      {
       item.BackColor = System.Drawing.Color.Red;//setting the background color for the row.
       item.ForeColor = System.Drawing.Color.Yellow;//setting the text color.
      }
 }

Thanks,
Shinu.
0
wdudek
Top achievements
Rank 1
answered on 11 Feb 2011, 10:47 PM
Thanks, that was exactly what I was looking for.

Bill
Tags
Grid
Asked by
wdudek
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
wdudek
Top achievements
Rank 1
Share this question
or