I have 2 Repeaters one inside another.
<div id="result">
<asp:Repeater runat="server" id="results">
<Itemtemplate>
<asp:Button ID="Button1" runat="server" Text="Add Color"></asp:Button>
<asp:Repeater runat="server">
<Itemtemplate>
<tr class="gradeX odd">
<asp:Button ID="Button2" runat="server" Text="Add Size"></asp:Button>
<td><asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></td>
<td><asp:TextBox ID="TextBox2" runat="server"></asp:TextBox></td>
</tr>
</Itemtemplate>
</asp:Repeater>
</Itemtemplate>
</asp:Repeater>
</div>
And on PageLoad I am populating both with DataBinding to List and List. The Button1 and Button2 is responsible for adding rows to each Repeater when clicked. The code is adding the rows to both perfectly but I noticed when I click the Buttons the data from the textbox isn’t posted to the server so I collect from code behind. Is there something wrong I am doing?
Make sure you re-bind your data on page postback as well. Page control tree needs to be recreated before you can access the posted values.
If you re-create and add the control in page_load, it would allow you to access the post back value, but any view state changes may get lost/over written.
If you can, then recreating the control tree in page_init results in cleanest solution as it would allow the dynamic controls view state to restored properly.
Read this excellent article on Dynamic Web Controls, Postbacks, and View State
See following for The ASP.NET Page Life Cycle