There is an important distinction between two events on the datagrid:
ItemDataBound and ItemCreated
As you have found, ItemDataBound fires when the item is databound (imagine that).
The ItemCreated event is fired every time an item is created for the grid. This means that it's fired when the grid is databound (rows generated) AND when the grid is reconstructed from ViewState. Another important note: the viewstate contains the data that was bound to the grid, but not the layout and such of the grid. Every time the page is executed, the grid is constructed from the data (whether it's new, i.e. when you call DataBind() or when it's from ViewState such as during a postback that doesn't involve changes to the grid data source).
SO... if you move the code that generates/modifies your custom grouping headers from ItemDataBound into ItemCreated you'll regenerate the custom layout without the need to rebind and thus loose the entered/changed data.
http://msdn.microsoft.com/library/en...eatedtopic.asp
-
Peter