Formview/Detailsview EditMode & FindControl

This stumped me for a bit today.

I changed a Formview to defaultmode=”edit” and found that FindControl would not work either in Page_Load or even in the FormView databound event – which I found very odd.

Anyway to solve it I just attached a function to the Prerender event for the controls I was trying to change values for (TextBox) and set it there.

Summary:

Page_Load or DataBound are no good for accessing controls on a Formview in Editmode.

Use the controls Prerender event to handle updating the control value before the page is displayed.