Subject: Why is Findcontrol Failing on a Repeater Postback?
Posted By: HD95 Post Date: 1/27/2006 10:07:03 AM
I got a page that displays records with a repeater

inside the repeater item records i have controls that get modified with the findcontrol method and they work fine when the page first loads. However, on postback the findcontrol method fails. When debugging the postback I noticed the The repeater itemcreated event is the first thing to happen. Whis is doing this without calling the datareader first?



Reply By: planoie Reply Date: 1/27/2006 10:29:54 AM
On every page hit, the controls have to be created.  Initially, the repeater has no internal data so it doesn't do anything.  Once you have databound some data to it, it can create its repeating items.  On a postback page hit, the repeater rebuild itself at the beginning of the page lifecycle.  When it does this, it raises the ItemCreated event for each item.  When you bind to the control, it also raises the ItemDataBound event for each item (ItemCreated first, then ItemDataBound).

-Peter
Reply By: HD95 Reply Date: 1/27/2006 1:21:15 PM
so what exactly needs to be added to my code?


Reply By: planoie Reply Date: 1/27/2006 8:46:50 PM
Post the relevant code so we can see what might be happening.

-Peter

Go to topic 39256

Return to index page 384
Return to index page 383
Return to index page 382
Return to index page 381
Return to index page 380
Return to index page 379
Return to index page 378
Return to index page 377
Return to index page 376
Return to index page 375