title: How do I bind a repeater to a List<Person> to also update the bound items? (2-way)
body: <p>If I have a List &lt; Person > where person is defined by the class</p>
  
  <pre><code>class Person
  {
     string Forename
     {
        get;set;
     }
     string Surname
     {
        get; set;
     }
  }
  </code></pre>
  
  <p>And I bind it to an asp repeater control that looks like this:</p>
  
  <pre><code>&lt;asp:Repeater ID="Repeater1" runat="server"&gt;
      &lt;ItemTemplate&gt;
          &lt;asp:Label ID="lblForename" runat="server" Text="Forname" AssociatedControlID="txtForename" /&gt;
          &lt;asp:TextBox ID="txtForename" runat="server" Text='&lt;%# ((Person)Container.DataItem).Forename %&gt;' /&gt;
          &lt;br /&gt;
          &lt;asp:Label ID="lblSurname" runat="server" Text="Forname" AssociatedControlID="txtSurname" /&gt;
          &lt;asp:TextBox ID="txtSurname" runat="server" Text='&lt;%# ((Person)Container.DataItem).Surname %&gt;' /&gt;
          &lt;br /&gt;
      &lt;/ItemTemplate&gt;
  &lt;/asp:Repeater&gt;
  </code></pre>
  
  <p>What is the best way to get the data that the user types in back into the objects?</p>
  
  <p>I thought that the whole point of data binding was that this was effectively handled for you, but when I inspect the Repeater1.Items collection, there are no changes made. Do I have to write code to do something along the lines of</p>
  
  <pre><code>//This is only intended to be pseudo code
  for each item in Repeater1.Items
      ((Person)item.DataItem).Forename = item.FindControl("txtForname").Text;
  end for
  </code></pre>
  
  <p>If that is the case, why is the DataItem property always empty?</p>
  
  <p><strong>Additional info:</strong></p>
  
  <p>I am already calling code the the effect of </p>
  
  <pre><code>this.Repeater1.DataSource =  this.PersonList;
  this.Repeater1.DataBind();
  </code></pre>
  
  <p>I've tried using <code>Bind("Forename")</code>, but this doesn't seem to bring the info from the TextBox back into the object, do I have to do this manually?</p>