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

[Solved] Question

1 Answer 217 Views
Grid
This is a migrated thread and some comments may be shown as answers.
nirbhay giri
Top achievements
Rank 1
nirbhay giri asked on 19 Mar 2010, 06:52 AM
how to give background color to RadGrid on any condition?  suppose I want to show a light red color to my Grid where Priority is High?

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 19 Mar 2010, 07:30 AM

Hello Nirbhay Giri,

If you want to set BackColor for the grid, then set the AlternatingItemStyle-BackColor and temStyle-BackColor properties to your custom color code.

ASPX:

 
  <telerik:RadGrid AlternatingItemStyle-BackColor="#e38282" ItemStyle-BackColor="#e38282" ID="RadGrid1"  . . . 

If you want to change the item style according to the cell value, then check for the value in ItemDatabound event and set the Item.BackColor property.

CS:

 
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)  
    {  
 
        if (e.Item is GridDataItem)  
        {  
            GridDataItem item = (GridDataItem)e.Item;  
            if (item["Priority"].Text == "High")  
            {  
                item.BackColor = System.Drawing.Color.Red;  
            }  
        }   
    } 

-Shinu.

Tags
Grid
Asked by
nirbhay giri
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or