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()
?
It is very odd. Did not work for me just calling DataBind(). I had to create a new List, add an item, set as datasource, then databin.
It has nothing to do with BINDING. One is looking for SERVER CONTROL, not for ITS BOUND DATA. SO - control should be available via FindControl. The reason is somewhere else...
Either explicitly call DataBind(), or place your code in the DataBound event of the FormView.
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.what I experienced is this,
returned
null
.So, I did this: