New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Differences Between ItemCreated and ItemDataBound

Here are some hints which can help you visualize the sequence of the ItemCreated and ItemDataBound events firing, their specifics and execution lifecycle:

 

Question Answer
Is there any data in the item? ItemCreated is fired -before- the item is data-bound. Thus, there is no data in the cells' text or input controls yet. In ItemDataBound all is available.
How often does it fire? ItemCreated is fired when grid is binding to data and when grid is binding from the ViewState, hence after each page postback - just before Load event occurs. ItemDataBound is fired only when grid binds to data. This means that if you need to add controls to a grid item that should fire a postback event, you should:
  1. Create the controls in ItemCreated event handler
  2. Bind them to data in ItemDataBound (if that's needed)
What about the ViewState management? ItemCreated should be hooked when you need to modify the controls inside a grid cell. ItemDataBound should be wired in order to change the data displayed inside a grid cell and its controls. The changes made in the ItemCreated / ItemDataBound handlers will be persisted in the ViewState.
In this article