日期:2014-05-17  浏览次数:20621 次

想用repeater嵌套repeater做个2级菜单
本帖最后由 u011335204 于 2013-09-25 14:04:21 编辑
区域(东北,华北,西北)是一级菜单,省份(沈阳,广东)是二级菜单
区域表(ID,name) 省份表(区域ID外键,省份名)
Repeater1 把每个区域查询出来,Repeater2每个区域的ID 查询出相应的省份,

死的HTML 效果图


我瞎写的代码

<div class="menu">
<ul>
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSourceQuyu">
                <ItemTemplate>
                    <li><a class="hide" href="###"><%# Eval("region")%></a>
                        <ul>
                            <asp:Repeater ID="Repeater2" runat="server" DataSourceID="SqlDataSourceQuyu2">
                                <ItemTemplate>
                                    <li><a href="###"><%# Eval("province")%></a></li>
                                </ItemTemplate>
                            </asp:Repeater>
                            <asp:SqlDataSource ID="SqlDataSourceQuyu2" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:zidaiHaiyang %>" 
                            SelectCommand='SELECT [RegionId], [ProductName], [province] FROM [RegionProduct] where [RegionId] =<%# Eval("id")%>' ></asp:SqlDataSource>
    //我想根据上一级的id查到此
                        </ul>
                    </li>
                </ItemTemplate>
             </asp:Repeater>
             <asp:SqlDataSource ID="SqlDataSourceQuyu" runat="server"