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

grid's item attributes programmatically

6 Answers 121 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Boris
Top achievements
Rank 1
Boris asked on 17 Aug 2010, 06:42 AM
Dear Sirs!
For RadGrid I want to change some item's attrfibutes. For example, border color width and style if some condition is true.
In ItemDataBound item I write:

 

if (e.Item is GridDataItem)

 

{

 

GridDataItem it = e.Item as GridDataItem;

 

 

try

 

{

 

if (it["track_type"].Text.Trim() == "0")

 

{

it.BorderColor = System.Drawing.

Color.Red;

 

}

}

 

catch { }

 

}

this not works but the it.BackColor = System.Drawing.Color.Red work OK.
What I did wrong?
May be I need to override Grid's Style of my skin?

Thank you very much in advance.

Boris


 

6 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 19 Aug 2010, 02:20 PM
Hello Boris,

Yes, the recommended approach for modifying the styles of the grid elements is through the CSS skin. You can either modify the CSS styles applied to the grid elements (through the preset CSS classes), or assign new CSS classes to your items.

Best,
Veli
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Boris
Top achievements
Rank 1
answered on 19 Aug 2010, 03:05 PM
OK, but the question is:
if I want to modify the CSS styles of the grid's element then I have:
1) to copy the corresponding .css files in my project,
2) modify needed elements and link my page with this file no touching the original files in Program Files. It is correct?

For example, I have to take grid's css filr from:
C:\Program Files\Telerik\RadControls for ASP.NET AJAX Q1 2010\Skins\Office20070Grid.Office2007.css -  right?

Thank you,
Boris
0
Veli
Telerik team
answered on 20 Aug 2010, 01:34 PM
Yes, this is the recommended approach. For details on how exactly you can proceed, refer to this help topic and other related topics in the same section.

Veli
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Boris
Top achievements
Rank 1
answered on 20 Aug 2010, 07:43 PM
Veli, thank you very much for exhaustive answer!
Boris
0
Mark
Top achievements
Rank 1
answered on 16 Dec 2010, 08:15 PM
I have a similar question along these lines but can't find the answer in this forum. I'm using a Custom Skin as well Skin="WC". We are using the Prior to the Q1 2009 release of RadGrid for ASP.NET AJAX. Any ideas? Or links to other forum entries? Thank you!

 

for (int i = 0; i < this.grdAccountLimits.Items.Count; i++)
{
    
GridDataItem gdi = this.grdAccountLimits.Items[i];
    
if (some check for error goes here)
    {
         // This Works
        
gdi.BackColor = System.Drawing.Color.Red;
        // This Does Not
        gdi.BorderColor = System.Drawing.Color.Red;
    }
}

 

0
Veli
Telerik team
answered on 20 Dec 2010, 12:33 PM
Hello Mark,

We have a help article on how to customize RadGrid's Skin. It starts with the description of the skin RadGrid uses prior to Q1 2009 and how  to customize that.

Veli
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
Boris
Top achievements
Rank 1
Answers by
Veli
Telerik team
Boris
Top achievements
Rank 1
Mark
Top achievements
Rank 1
Share this question
or