How do I get 2-way data binding to work for nested asp.net Repeater controls
- by jimblanchard
I have the following (trimmed) markup:
<asp:Repeater ID="CostCategoryRepeater" runat="server">
<ItemTemplate>
<div class="costCategory">
<asp:Repeater ID="CostRepeater" runat="server" DataSource='<%# Eval("Costs")%>'>
<ItemTemplate>
<tr class="oddCostRows">
<td class="costItemTextRight"><span><%# Eval("Variance", "{0:c0}")%></span></td>
<td class="costItemTextRight"><input id="SupplementAmount" class="costEntryRight" type="text" value='<%# Bind("SupplementAmount")%>' runat="server" /></td>
</tr>
</ItemTemplate>
</asp:Repeater>
</div>
</ItemTemplate>
</asp:Repeater>
The outer repeater's DataSource is set in the code-beside. I've snipped them, but there are Eval statements that wire up to the properties in the outer Repeater. Anyway, one of the fields in the inner Repeater needs to be a Bind instead of an Eval, as I want to get the values that the user types in. The SupplementAmount input element correctly receives it's value when the page loads, but on the other side, when I inspect the contents of the Costs List when the form posts back, the changes the user made aren't present. Thanks.