Why method FindControl()
returns null
on FormView
until call DataBind()
.
After that it returns everything correctly?
What workaround are there?
Call DataBind()
before first call of FindControl()
?
Why method FindControl()
returns null
on FormView
until call DataBind()
.
After that it returns everything correctly?
What workaround are there?
Call DataBind()
before first call of FindControl()
?
How would a FormView
have any information about its content before it has any data to build it upon?
So I guess you already answered your own question, you will have to DataBind()
before.
Either explicitly call DataBind(), or place your code in the DataBound event of the FormView.