2

我有下面的嵌套中继器,我需要从父中继器返回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()
4

1 回答 1

1

替换ID_Parent=<% '?????? %>为:

<%# DataBinder.Eval(((RepeaterItem)Container.Parent.Parent).DataItem, "ID")%>
于 2018-03-03T09:14:18.557 回答