While I haven't worked a whole lot with the grid view itself, the way I used to achieve custom formatting of the ASP.NET 1.1 datagrid control was to handle it inside the ItemCreated event. Inside the handler you can test the datagrid(view) item type. When it's the Header item, you can modify the cells collection of "e.Item" and manipulate as desired.
Here's a short article of using the ItemDataBound event:
http://www.codeproject.com/aspnet/ItemCreated.asp
and the documentation from MSDN:
http://msdn2.microsoft.com/en-us/lib...databound.aspx
Here's the docs on ItemCreated:
http://msdn2.microsoft.com/en-us/lib...emcreated.aspx
An important distinction between ItemDataBound and ItemCreated that isn't well documented is this:
- ItemCreated is called EVERY time the grid is constructed (i.e. on grid data bind as well as on a postback when the grid is being REconstructed even if you don't explicitly do anything to it).
- ItemDataBound is ONLY called when you call the DataBind() method. If you use this event to reformat the control, it will look good after a page hit where the grid is data bound, but not on a non-binding postback.
-
Peter