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

Changing background color for particular columns

2 Answers 116 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 24 Sep 2009, 03:57 AM
I'm trying to change the alternate row background color for particular columns so that they are different from the applied skin that appears in the remaining columns and I'm not sure what I'm doing wrong.

Here is my CSS:
    <style type="text/css">  
         div.MfgClass tr.rgAltRow  
         {  
           background-colorred;  
         }  
    </style> 

And here is my HTML:
        <telerik:GridBoundColumn DataField="manufacturer"   
            HeaderText="Mfg" SortExpression="manufacturer"   
            UniqueName="manufacturer" ItemStyle-CssClass="MfgClass">  
            <HeaderStyle Font-Bold="True" HorizontalAlign="Center" VerticalAlign="Middle" />  
        </telerik:GridBoundColumn> 

Any help would be greatly appreciated.

Thanks,
Tim

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 24 Sep 2009, 07:17 AM
Hi Tim,

Try out the following code in order to achieve the required.

C#:
 
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    if( e.Item.ItemType == GridItemType.AlternatingItem ) 
    { 
        GridDataItem item = (GridDataItem)e.Item; 
        item["CustomerID"].BackColor = System.Drawing.Color.Red; 
    } 

-Shinu.
0
Tim
Top achievements
Rank 1
answered on 24 Sep 2009, 03:58 PM
Shinu,

Thanks for the reply.  I dropped in the code just as you show, but nothing changes.  The column I used to test has the same alternating row background color as the rest of the columns.  Any idea what I might be doing wrong?

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