ASP.NET Repeater ItemDataBound happening AFTER PreRender event?

Matias Nino picture Matias Nino · Oct 20, 2008 · Viewed 18.2k times · Source

I have a repeater control on an ASP.NET 2.0 web form.

As I understanding it, all of the page's data-bound controls fire their binding events somewhere in between the Page_Load and the Page_PreRender events.

However, my repeater's ItemDataBound event appears to be happening AFTER the PreRender event.

How is this so and is there any way I can access the page controls AFTER all the ItemDataBound events have fired?

Updates:

  • The Repeater uses an ObjectDataSource with the DataSourceID declarative set in the repeater control.

  • The DataSource ID or object is not modified at all during the page life-cycle.

Answer

Atanas Korchev picture Atanas Korchev · Oct 20, 2008

Declarative databinding (datasource specified via the DataSourceID property) occurs later than the PreRender event. The behavior you are observing is by design. If this is not what you need you should explicitly databind your control - just call its DataBind method.