repeater嵌套
1
<asp:Repeater ID="repeaterParent" runat="server" OnItemDataBound="repeaterParent_ItemDataBound">
2
<ItemTemplate>
3
<!---------------------------------------------------------------------------------------->
4
<table width="186" border="1" class="MenuTB">
5
<tr>
6
<th style="cursor:pointer;">
7
<img src="images/comments.gif" / alt=""><%#Eval("MenuText") %>
8
</th>
9
</tr>
10
<tr style="display:none">
11
<td>
12
<ul>
13
<asp:Repeater ID="repeaterMinMenu" runat="server">
14
<ItemTemplate>
15
<li>
16
<a href="<%#Eval("MenuLink") %>" target="frmContent"><%#Eval("MenuText") %></a></li>
17
</ItemTemplate>
18
</asp:Repeater>
19
</ul>
20
</td>
21
</tr>
22
</table>
23
<!----------------------------------------------------------------------------------------->
24
</ItemTemplate>
25
</asp:Repeater>
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
4
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
5
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
6
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
7
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
8
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
9
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
10
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
11
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
12
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
13
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
14
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
15
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
16
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
17
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
18
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
19
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
20
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
21
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
22
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
23
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
24
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
25
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
C#:
1
protected void BindParentRepeaterData()//绑定父repeater数据
2
{
3
string SqlGetParentMenu = @"SELECT MenuId,MenuText FROM website_Menu WHERE ParentId IS NULL OR ParentId=0";
4![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
5
DataTable dtGetParentMenu = SqlHelper.ExecuteDataset(Configurations.RemoteConnectionString, CommandType.Text, SqlGetParentMenu).Tables[0];
6![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
7
repeaterParent.DataSource = dtGetParentMenu;
8![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
9
repeaterParent.DataBind();
10
}
11![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
12![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
13
protected void repeaterParent_ItemDataBound(object sender, RepeaterItemEventArgs e)
14
{
15
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
16
{
17
int MenuId = Convert.ToInt32(((DataRowView)e.Item.DataItem).Row["MenuId"]);
18![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
19
Repeater repeaterMinMenu = (Repeater)e.Item.FindControl("repeaterMinMenu");
20![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
21
if (repeaterMinMenu != null)
22
{
23
string SqlGetMinMenu = string.Format(@"SELECT A.MenuId,A.ParentId,A.MenuText,A.MenuLink FROM dbo.website_Menu A
24
INNER JOIN dbo.website_RolesMenu B
25
ON A.MenuId = B.MenuId AND A.ParentId = {0}
26
INNER JOIN dbo.User_UsersRoles C
27
ON B.RoleId = C.RoleId AND C.UserId = {1}
28
GROUP BY A.MenuId,A.ParentId,A.MenuText,A.MenuLink ",MenuId,Kuqu.Components.Tickets.UserInfo.Id);
29![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
30
DataTable dtGetMinMenu = SqlHelper.ExecuteDataset(Configurations.RemoteConnectionString, CommandType.Text, SqlGetMinMenu).Tables[0];
31![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
32
repeaterMinMenu.DataSource = dtGetMinMenu;
33![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
34
repeaterMinMenu.DataBind();
35
}
36
}
37
}
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
3
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
4
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
5
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
6
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
7
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
8
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
9
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
10
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
11
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
12
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
13
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
14
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
15
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
16
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
17
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
18
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
19
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
20
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
21
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
22
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
23
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
24
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
25
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
26
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
27
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
28
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
29
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
30
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
31
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
32
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
33
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
34
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
35
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
36
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
37
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)