Unable to get the child control in repeater when first page load

  • Thread starter Thread starter jl817cn
  • Start date Start date
J

jl817cn

It's strange.

The page is using master page, the repeater control is placed in
contentplaceholder. In repeater Itemtemplate, there are several labels
and textboxes, the value of textboxes is from database. there is
another custom control in repeater, which inherit the label control,
just add one customer property MyID. In page_load I will also call
another function to set the text of custom label. the function loop
through all the controls in page and set the value.

But if when the page is loaded for the first time, custom label does
not display the data retrieve from function, but in postback, it
display!

In debug, I found in the first page load, the function only finds
repeater control, but no repeateritem at all.

By the way, I am using recursive getControl method to get all the
control, which i believe is correct.

Thank you for any help!

Best

C^^
 
Hi

If you use DataSourceID property for automatic data binding, data binding
occurs after the Page_Load and you cannot see any items. On the PostBack
state of repeater is restored from the ViewState and you can access these
items.

You will not see items created util OnPrerenderComplete event.

-yuriy
 
Back
Top