title: How to reference dynamically created controls?
body: <p>Is there a way to reference dynamically created controls, such as a couple TextBoxes and maybe a RadioButtonList when the user either click a button or changes the selected radio button.</p>
  
  <p>I need to insert a record into a database but I need all of the values. I cannot hard-code the controls because they must be created on the fly.</p>
  
  <pre><code>TextBox t1 = new TextBox();
  PlaceHolder1.Controls.Add(t1);
  
  TextBox t2 = new TextBox();
  PlaceHolder1.Controls.Add(t2);
  
  RadioButtonList rbList = new RadioButtonList();
  rbList.Items.Add(new ListItem("Today", "1"));
  rbList.Items.Add(new ListItem("This Week", "2"));
  rbList.SelectedIndexChanged += new EventHandler(rbList_SelectedIndexChanged);
  
  PlaceHolder1.Controls.Add(rbList);
  </code></pre>
  
  <p>I need to reference the two textboxes and the RadioButtonList within rbList_SelectedIndexChanged or some other event. Adding EventHandlers to the textboxes do my no good because I need all three values to insert into the database. </p>
  
  <p>My inital thought was to somehow pass reference of the texboxes to the rbList_SelectedIndexChanged event but I am unsure of how to do this and even more unsure if it will even work.</p>
  
  <p>Any help would be appreciated.</p>