Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Repeater ItemDataBound happening AFTER PreRender event?

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.

like image 480
Matias Nino Avatar asked Oct 20 '08 18:10

Matias Nino


2 Answers

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.

like image 131
Atanas Korchev Avatar answered Nov 05 '22 22:11

Atanas Korchev


Are you specifically binding your repeater (myRepeater.DataBind();) in your code behind file (for example inside the Page_Load() event)?

Have you checked out the ASP.NET events lifecycle? Sorry if you already know this, but just in case: http://msdn.microsoft.com/en-us/library/ms178472.aspx

Hope it helps.

Ricardo.

like image 27
Ricardo Villamil Avatar answered Nov 05 '22 22:11

Ricardo Villamil