<Caicai:CRepeater ID="CRepeater1" runat="server">
<ItemTemplate>
<h1><%# Eval("id")%></h1><span><%# Eval("name")%></span>
<Caicai:CRepeater ID="CRepeater2" runat="server">
<ItemTemplate>
<h2><%# Eval("id")%></h2><span><%# Eval("name")%></span>
</ItemTemplate>
</Caicai:CRepeater>
</ItemTemplate>
</Caicai:CRepeater>
子级(CRepeater2)里的<%# Eval("name")%>怎么能取到父级(CRepeater2)的<%# Eval("name")%>
意思就是子级(CRepeater2)里的<%# Eval("name")%>需要显示的数据是父级(CRepeater2)的
求助...
------解决方案--------------------------------------------------------
- HTML code
<Caicai:CRepeater ID="CRepeater1" runat="server"> <ItemTemplate> <h1> <%# Eval("id")%> </h1> <span> <%# Eval("name")%> </span> <Caicai:CRepeater ID="CRepeater2" runat="server"> <ItemTemplate> <h2> <%# Eval("id")%> </h2> <span> <%# Eval("name")%> </span> </ItemTemplate> </Caicai:CRepeater> </ItemTemplate> </Caicai:CRepeater>
------解决方案--------------------------------------------------------
推荐非反射
假如你绑定的数据源是 DataTable/DataView/DataSet
<%# ((Container.NamingContainer.NamingContainer as RepeaterItem).DataItem as DataRowView)["name"] %>
实体类
<%# ((Container.NamingContainer.NamingContainer as RepeaterItem).DataItem as MyEntity).TheNameProperty %>