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

change color for selected columns

1 Answer 61 Views
Grid
This is a migrated thread and some comments may be shown as answers.
newbie
Top achievements
Rank 1
newbie asked on 31 Jul 2008, 12:16 AM
Is it possible to display some columns in a different color than others based on some condition.

What I want here is I have a grid which displays days of week.
I want to display my sat and sun columns in a different color or if the day is a holiday then in a different color.

Is this possible?

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 31 Jul 2008, 06:05 AM
Hello,

I'm not sure if this is what you require but to set the color of a particular column and cell you can try the following code.

cs:
 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            item["ColumnUniqueName"].BackColor = System.Drawing.Color.Blue; 
            string strtx = item["ColumnUniqueName"].Text; 
            if (strtx == "holiday") 
            { 
                // set the back color of the Cell 
                item["ColumnUniqueName"].BackColor = System.Drawing.Color.Red; 
            }             
        } 
    } 

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