title: dynamically call a control
body: <p>Let's say I have 30 controls, all lbls, all called "lblA" with a number after.</p>
  
  <p>I also have 30 textboxes, same thing - called "txtB" with a number after.</p>
  
  <p>How exactly would I formated this.</p>
  
  <pre><code>for (i = 1; i &lt; this.controls.count;i++)
  {
      if ("lblA"+i=null)
      {
          break;
      }
      string A = string A + ("lblA" + i).Text
      string B = string B + ("txtB" + i).Text
  }
  </code></pre>
  
  <p>I've tried a few different things like calling the object with this.controls[i] but it's not exactly what I want. What I am doing is I have a lot of labels and text boxes in a form that are added at run time. I need to loop through the form to get them all. I'm writting it as a for each with quite a few ifs, but I'm curious if there's a dynamic way to do it.</p>
  
  <p>I've looked for about 1-1:30 hours online and found nothing close to, thanks for the help all.</p>