How do I get 2-way data binding to work for nested asp.net Repeater controls

Posted by jimblanchard on Stack Overflow See other posts from Stack Overflow or by jimblanchard
Published on 2010-03-12T02:32:55Z Indexed on 2010/03/12 2:37 UTC
Read the original article Hit count: 216

Filed under:
|

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.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about databinding