如何使嵌套的ASP.NET Repeater控件实现双向数据绑定?

3
我有以下(精简版)的标记语言:
<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>

外层重复器的数据源在代码中被设置。我已经剪掉了它们,但是有一些Eval语句将其连接到外部Repeater的属性。不管怎样,内部Repeater中的一个字段需要是绑定而不是Eval,因为我想获取用户输入的值。当页面加载时,SupplementAmount输入元素正确接收它的值,但是在另一侧,当表单提交时检查Costs列表的内容时,用户所做的更改并不存在。谢谢。

1个回答

0

无法在Repeater控件中使用Bind方法。Bind方法仅适用于GridView、DetailsView和FormView控件。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接