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

Coloring of grid columns

5 Answers 95 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Priya
Top achievements
Rank 1
Priya asked on 06 Aug 2008, 04:23 AM
Sir
How to give different color to each column of grid

Thanks

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 06 Aug 2008, 05:18 AM
Hi Priya,

Try the following code snippet to set backcolor of Grid columns depending on their column UniquName.

CS:
 protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
        
        foreach (GridColumn col in RadGrid1.MasterTableView.RenderColumns) 
        { 
            if (col.UniqueName == "ProductName") 
            { 
                col.HeaderStyle.BackColor = System.Drawing.Color.Pink; 
                col.ItemStyle.BackColor = System.Drawing.Color.Pink; 
            } 
            else if (col.UniqueName == "ProductID") 
            { 
                col.HeaderStyle.BackColor = System.Drawing.Color.Plum ; 
                col.ItemStyle.BackColor = System.Drawing.Color.Plum; 
            } 
        } 
    } 


Thanks
Shinu.
0
Anil
Top achievements
Rank 2
answered on 06 Aug 2008, 05:28 AM
Hi Priya,

Or you can give a different color to the alternate rows using your CSS file.
For example like in Office2007 skin you can add "background:#C4DDFF;" in GridAltRow_Office2007 td class:-

.GridAltRow_Office2007 td
{
    background:#C4DDFF;
    font-family:Arial;
    font-size:11px;
    overflow: hidden;
    text-overflow: ellipsis;
}

Hope it helps you.

Thanks
Anil
0
Priya
Top achievements
Rank 1
answered on 06 Aug 2008, 05:37 AM
But when i select the row ,selected row color is not applied in the colored row
0
Anil
Top achievements
Rank 2
answered on 06 Aug 2008, 05:51 AM
Hi Priya,

For selected row you have to modify

.SelectedRow_Office2007 td,
.ActiveRow_Office2007 td classes..

e.g.:-

.SelectedRow_Office2007 td,
.ActiveRow_Office2007 td
{
    background : #A7CDF0;
    font-family:
Arial;
    font-size:11px;
}
0
Princy
Top achievements
Rank 2
answered on 06 Aug 2008, 06:46 AM
Hi Priya,

You can also refer the following help article which explains how to modify existing skin for RadGrid.

Modifying existing skins/creating new skins
Customizing row appearance

Regards
Princy.
Tags
Grid
Asked by
Priya
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Anil
Top achievements
Rank 2
Priya
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or