repeater嵌套

 1None.gif    <asp:Repeater ID="repeaterParent" runat="server"  OnItemDataBound="repeaterParent_ItemDataBound">
 2None.gif        <ItemTemplate>
 3None.gif            <!---------------------------------------------------------------------------------------->
 4None.gif            <table width="186" border="1" class="MenuTB">
 5None.gif                <tr>
 6None.gif                    <th style="cursor:pointer;">
 7ExpandedBlockStart.gifContractedBlock.gif                        <img src="images/comments.gif" / alt=""><%dot.gif#Eval("MenuText"%>
 8None.gif                    </th>
 9None.gif                </tr>
10None.gif                <tr style="display:none">
11None.gif                    <td>
12None.gif                        <ul>
13None.gif                            <asp:Repeater ID="repeaterMinMenu" runat="server">
14None.gif                                <ItemTemplate>
15None.gif                                    <li>
16ExpandedBlockStart.gifContractedBlock.gif                                        <href="<%#Eval("MenuLink") %>" target="frmContent"><%dot.gif#Eval("MenuText"%></a></li>
17None.gif                                </ItemTemplate>
18None.gif                            </asp:Repeater>
19None.gif                        </ul>
20None.gif                    </td>
21None.gif                </tr>
22None.gif            </table>
23None.gif            <!----------------------------------------------------------------------------------------->
24None.gif        </ItemTemplate>
25None.gif    </asp:Repeater>

C#:
 1None.gif        protected void BindParentRepeaterData()//绑定父repeater数据
 2ExpandedBlockStart.gifContractedBlock.gif        dot.gif{
 3InBlock.gif            string SqlGetParentMenu = @"SELECT MenuId,MenuText FROM website_Menu WHERE ParentId IS NULL OR ParentId=0";
 4InBlock.gif
 5InBlock.gif            DataTable dtGetParentMenu = SqlHelper.ExecuteDataset(Configurations.RemoteConnectionString, CommandType.Text, SqlGetParentMenu).Tables[0];
 6InBlock.gif
 7InBlock.gif            repeaterParent.DataSource = dtGetParentMenu;
 8InBlock.gif
 9InBlock.gif            repeaterParent.DataBind();
10ExpandedBlockEnd.gif        }

11None.gif
12None.gif
13None.gif        protected void repeaterParent_ItemDataBound(object sender, RepeaterItemEventArgs e)
14ExpandedBlockStart.gifContractedBlock.gif        dot.gif{
15InBlock.gif            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
16ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
17InBlock.gif                int MenuId = Convert.ToInt32(((DataRowView)e.Item.DataItem).Row["MenuId"]);
18InBlock.gif
19InBlock.gif                Repeater repeaterMinMenu = (Repeater)e.Item.FindControl("repeaterMinMenu");
20InBlock.gif
21InBlock.gif                if (repeaterMinMenu != null)
22ExpandedSubBlockStart.gifContractedSubBlock.gif                dot.gif{
23InBlock.gif                    string SqlGetMinMenu = string.Format(@"SELECT A.MenuId,A.ParentId,A.MenuText,A.MenuLink   FROM dbo.website_Menu A
24InBlock.gif                                                            INNER JOIN dbo.website_RolesMenu B 
25InBlock.gif                                                            ON A.MenuId = B.MenuId  AND A.ParentId = {0}
26InBlock.gif                                                            INNER JOIN dbo.User_UsersRoles C 
27InBlock.gif                                                            ON B.RoleId = C.RoleId AND C.UserId = {1}
28InBlock.gif                                                            GROUP BY A.MenuId,A.ParentId,A.MenuText,A.MenuLink ",MenuId,Kuqu.Components.Tickets.UserInfo.Id);
29InBlock.gif
30InBlock.gif                    DataTable dtGetMinMenu = SqlHelper.ExecuteDataset(Configurations.RemoteConnectionString, CommandType.Text, SqlGetMinMenu).Tables[0];
31InBlock.gif
32InBlock.gif                    repeaterMinMenu.DataSource = dtGetMinMenu;
33InBlock.gif
34InBlock.gif                    repeaterMinMenu.DataBind();
35ExpandedSubBlockEnd.gif                }

36ExpandedSubBlockEnd.gif            }

37ExpandedBlockEnd.gif        }

转载于:https://www.cnblogs.com/cnzhouhai/archive/2007/09/26/906278.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值