Random topic – as you all know, it is well worth your time to use the SPGridView control because you can build really neat looking Data Grids from within SharePoint, that LOOK a lot like SharePoint – eg:

However, I had some specific requirements on colors/fonts and I needed to set a custom CSS class to my grid's CssClass property. I was having trouble getting this to work because it appeared the SPGridView kept over riding my changes within CreateChildControls. So, I overwrote OnPreRender and it worked! Here's my code:
public
class
SomeWebPart: System.Web.UI.WebControls.WebParts.WebPart
{
SPGridView grid;
protected
override
void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
grid.CssClass = "works";
}
protected
override
void CreateChildControls()
{
base.CreateChildControls();
grid = new
SPGridView();
//grid.CssClass = "does't work";
//grid.Attributes["class"] = "doesn't work";
// add columns, etc.
this.Controls.Add(grid);
}
}
Seems like the base class sets CSS and style propers in pre render – I guess that makes sense J
Phil