如何 return 父字段值到内部转发器?
How to return parent field value to inner repeater?
我有下面的嵌套中继器,我需要 return ID
来自父中继器的值,然后将其放入嵌套中继器中。
ID_Parent=<% '?????? %>
:
<asp:Repeater runat="server" ID="rp_outer">
<ItemTemplate>
<div id="<%#Eval("ID") %>">
<h4><%#Eval("Ename") %></h4>
<ul class="menu-items">
<asp:Repeater runat="server" ID="rp_inner_floorg" Visible="true"
DataSource='<%#(Container.DataItem).Row.GetChildRows("rltbls") %>'>
<ItemTemplate>
<li>
<a href='Products.aspx?ID_Parent=<% '?????? %>&InnerID=<%#CType(Container.DataItem, DataRow)("ID")%>'>
</a>
</li>
</ItemTemplate>
</asp:Repeater>
</ul>
</div>
</ItemTemplate>
</asp:Repeater>
**code-behind**
'Parrent
varSql = "SELECT ID,CatEname,HeadImg from qrywebsite_OuterMenue"
DataAdapter_1 = New SqlDataAdapter(varSql, varDbconn)
DataAdapter_1.Fill(ds, "tblCategory")
'Child
varSql = "select ID,Cat_Fkey,[SubCatEname] from qrywebsite_InnerSubCatMenu order by [Sequence]"
DataAdapter_2 = New SqlDataAdapter(varSql, varDbconn)
DataAdapter_2.Fill(ds, "tblSubCate")
ds.Relations.Add("rltbls", ds.Tables(0).Columns("ID"), ds.Tables(1).Columns("Cat_Fkey"), False)
ds.Relations("rltbls").Nested = true
rp_outer_catwgroy.DataSource = ds.Tables(0)
rp_outer_catwgroy.DataBind()
ds.Dispose()
DataAdapter_1.Dispose()
将ID_Parent=<% '?????? %>
替换为:
<%# DataBinder.Eval(((RepeaterItem)Container.Parent.Parent).DataItem, "ID")%>
我有下面的嵌套中继器,我需要 return ID
来自父中继器的值,然后将其放入嵌套中继器中。
ID_Parent=<% '?????? %>
:
<asp:Repeater runat="server" ID="rp_outer">
<ItemTemplate>
<div id="<%#Eval("ID") %>">
<h4><%#Eval("Ename") %></h4>
<ul class="menu-items">
<asp:Repeater runat="server" ID="rp_inner_floorg" Visible="true"
DataSource='<%#(Container.DataItem).Row.GetChildRows("rltbls") %>'>
<ItemTemplate>
<li>
<a href='Products.aspx?ID_Parent=<% '?????? %>&InnerID=<%#CType(Container.DataItem, DataRow)("ID")%>'>
</a>
</li>
</ItemTemplate>
</asp:Repeater>
</ul>
</div>
</ItemTemplate>
</asp:Repeater>
**code-behind**
'Parrent
varSql = "SELECT ID,CatEname,HeadImg from qrywebsite_OuterMenue"
DataAdapter_1 = New SqlDataAdapter(varSql, varDbconn)
DataAdapter_1.Fill(ds, "tblCategory")
'Child
varSql = "select ID,Cat_Fkey,[SubCatEname] from qrywebsite_InnerSubCatMenu order by [Sequence]"
DataAdapter_2 = New SqlDataAdapter(varSql, varDbconn)
DataAdapter_2.Fill(ds, "tblSubCate")
ds.Relations.Add("rltbls", ds.Tables(0).Columns("ID"), ds.Tables(1).Columns("Cat_Fkey"), False)
ds.Relations("rltbls").Nested = true
rp_outer_catwgroy.DataSource = ds.Tables(0)
rp_outer_catwgroy.DataBind()
ds.Dispose()
DataAdapter_1.Dispose()
将ID_Parent=<% '?????? %>
替换为:
<%# DataBinder.Eval(((RepeaterItem)Container.Parent.Parent).DataItem, "ID")%>