title: Get dynamic controls and text in Repeater
body: <p>I have a Repeater which loads some data from a SQL database</p>
  
  <pre><code>&lt;asp:Repeater ID="Repeater" runat="server" OnItemDataBound="Repeater_ItemDataBound"&gt;
      &lt;ItemTemplate&gt;
          &lt;asp:Label ID="QuestionLabel" runat="server" Text=""&gt;&lt;/asp:Label&gt;
          &lt;asp:TextBox ID="AnswerLabel" runat="server"&gt;&lt;/asp:TextBox&gt;
      &lt;/ItemTemplate&gt;
  &lt;/asp:Repeater&gt;
  
  &lt;asp:Button ID="AnswerSubmit" runat="server" Text="Insert"/&gt;
  </code></pre>
  
  <p>In code behind, i assign to get the questions on another button click to load and bind the Repeater. In ItemDataBound i find the controls and assign the questions to the label.</p>
  
  <p>How should i get the answers that the user enters and store the ID of the question with the answer they enter in a button click event?</p>
  
  <p>At first, I tried this in the button click event</p>
  
  <pre><code>foreach (RepeaterItem item in Repeater.Items)
  {
      Label QuestionLabel = (Label)item.FindControl("QuestionLabel");
  }
  </code></pre>
  
  <p>but it couldnt find the <code>QuestionLabel</code>. Looking at the page source i believe thats due to the label having a different value (QuestionLabel_0, QuestionLabel_1 etc), so struggling to find a way to approach this?</p>
  
  <p>Edit</p>
  
  <pre><code>    protected void QuestionButton_Click(object sender, EventArgs e)
      {
          Repeater.DataSource = QuestionsByID(ID);
          Repeater.DataBind();
      }
  </code></pre>