Friday, January 22, 2010

DataBind not always after Page.PreRender...

So I just spent hours following Microsoft's Lifecycle Page, wondering why and how my GridView with a DataSourceId was binding AFTER the OnPreRender method on my Page.

It literally says (see those bold letters):


PreRender

Before this event occurs:

The PreRender event occurs for each control on the page. Use the event to make final changes to the contents of the page or its controls.



And...It is wrong. Your controls may start DataBinding before PreRender, but they are not DataBound until after PreRender is called.

0 comments: