巢狀Repeater獲取父級控制元件的值
阿新 • • 發佈:2019-02-20
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
OrderID: <%# Eval("OrderID")%>
CustomerID :
<asp:Label ID="Label1" runat="server" Text='<%#Eval("CustomerID")%>'></asp:Label> <br />
<asp:Repeater ID="Repeater2" runat="server" DataSource='<%# GetOrderDetails(Convert.ToInt32(Eval("OrderID"))) %>'>
<ItemTemplate>
</ItemTemplate>
</asp:Repeater>
<br />
</ItemTemplate>
</asp:Repeater>
<ItemTemplate>
OrderID: <%# Eval("OrderID")%>
CustomerID :
<asp:Label ID="Label1" runat="server" Text='<%#Eval("CustomerID")%>'></asp:Label> <br />
<asp:Repeater ID="Repeater2" runat="server" DataSource='<%# GetOrderDetails(Convert.ToInt32(Eval("OrderID"))) %>'>
<ItemTemplate>
子容器得到CustomerID :
<%# ((Label)((RepeaterItem)((Repeater)(((RepeaterItem)Container).NamingContainer)).NamingContainer).FindControl("Label1")).Text %>
UnitPrice: <%#Eval("UnitPrice")%> <br /></ItemTemplate>
</asp:Repeater>
<br />
</ItemTemplate>
</asp:Repeater>