Find Controls in Repeaters

This usually happens to me. I have a repeater object, do a "FindControl" to look for a textbox, and can't find it. Ends up null each time.

So, tired of finding complex workarounds...I finally researched this issue.

Here's the solution:
 
Code:
foreach(RepeaterItem item in Repeater1.Items)
   {
      TextBox b = item.FindControl("TextBox1") as TextBox;
      Response.Write(b.Text + "<br>");                      
   }


Ahhh....makes much sense  Very Happy

Must love the internet Very Happy

Source: http://www.odetocode.com/articles/116.aspx

 

What did you think of this article?




Trackbacks
  • No trackbacks exist for this post.
Comments
  • No comments exist for this post.
Leave a comment

Submitted comments are subject to moderation before being displayed.

 Name (required)

 Email (will not be published) (required)

Your comment is 0 characters limited to 3000 characters.