日期:2014-05-19  浏览次数:20438 次

在Repeater中嵌套使用Repeater
谁能告诉我。在Repeater中嵌套使用Repeater怎么写,给份完整的代码。谢谢

------解决方案--------------------
可以嵌套使用的!!比如说在论坛上使用,大类版块和小类版块的循环。不过我的做法是大类使用的是“DATALIST”:protected System.Web.UI.WebControls.DataList rep_boardlist;
小类使用的是“Repeater ”:protected System.Web.UI.WebControls.Repeater rep_smallboard;

具体页面中代码如下:

<asp:DataList ID= "rep_boardlist " Runat= "server " Width= "100% " >
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<DIV align=center>
<DIV class= "spaceborder spacebottom " style= "CLEAR: both; MARGIN-TOP: 5px; WIDTH: 98% ">
<TABLE cellSpacing= "0 " cellPadding= "4 " width= "100% " align= "center ">
<TR>
<TD class= "header " style= "PADDING-LEFT: 20px " colSpan= "7 ">
<DIV class= "subtable " style= "PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px ">
<DIV class= "right "> <FONT color= "#154ba0 "> 分类版主: <A href= "# ">
<%#DataBinder.Eval(Container.DataItem, "Forum_BigClass_manager ")%>
</A> </FONT> <A onClick= "toggle_collapse( 'category_1 '); " href= "### ">
<IMG id= "category_1_img " alt= " " src= "images/collapsed_no.gif " border= "0 "> </A> &nbsp;
</DIV>
<A href= "# ">
<%#DataBinder.Eval(Container.DataItem, "Forum_BigClass_name ")%>
</A>
</DIV>
</TD>
</TR>
<asp:DataList Width=100% ID= "rep_smallboard " Runat= "server " DataSource= ' <%# ((System.Data.DataRowView)(Container.DataItem)).CreateChildView( "relations ")%> ' DataKeyField= "Forum_SmallClass_id ">
<HeaderTemplate>
<TBODY id= "category_1 ">
<TR class= "category " align= "center ">
<TD width= "5% "> &nbsp; </TD>
<TD align= "left " width= "56% "> 论坛 </TD>
<TD width= "5% "> 主题 </TD>
<TD width= "5% "> 帖数 </TD>
<TD width= "13% "> 最后发表 </TD>
<TD width= "16% "> 版主 </TD>
</TR>
</HeaderTemplate>
<ItemTemplate>
<TR class= "row " onMouseOver= "this.className= 'row1 ' " onmouseout= "this.className= 'row ' ">
<TD align= "center " width= "5% "> <IMG alt= " " src= "images/forum.gif "> </TD>
<TD class= "subject " align= "left " width= "56% "> <A href= 'board.aspx?smallid= <%#DataBinder.Eval(Container.DataItem, "Forum_SmallClass_Id ")%> '> <SPAN class= "bold "> 『 <%#DataBinder.Eval(Container.DataItem, "Forum_SmallClass_name ")%> 』 </SPAN> </A>
<BR>
<SPAN class= "smallt