简体   繁体   中英

C# Page.FindControl returns null on dynamic controls

I have two pages on which I bound dynamic controls . All the controls what I bound are TextBox es. Whenever I tried to retrieve the values of the controls in first page using

Page.Findcontrol("ctl00$cph_cabFest$AccountNumber")

It gives the proper result. But the second page gives the result as NULL. What could be the exact issue? Could anyone suggest me some way to identify this?

Just take a look at your event cycle . The best way to overcome these kind of issues is to bind the controls in Page_Init as well. There might be another reason for this. Bind your Panel in each PostBack request.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM