Repeater 嵌套
aspx.
View Code
<div class="fr A_blog34">
<div class="A_blog252"></div>
<asp:Repeater ID="RepBlogSections" runat="server"
onitemcreated="RepBlogSections_ItemCreated"
onitemdatabound="RepBlogSections_ItemDataBound">
<ItemTemplate>
<div class="A_blog41">
<div id="Dtop" class="A_blog40 top1" runat="server"></div>
<div class="fl A_blog28" style="width:50px; height:50px;"><a href="/u/<%# GetLoginName(Convert.ToInt32(Eval("OwnerUserID")))%>.aspx" target="_blank"><img width="50" height="50" src="http://blog.22-cf.com/services/UserAvatar.ashx?UserID=<%# Eval("OwnerUserID") %>&AvatarType=0&AvatarSizeType=2"/></a></div>
<div class="A_blog44">
<h3 class="f12 fw"><a href="/u/<%# GetLoginName(Convert.ToInt32(Eval("OwnerUserID")))%>/Blog.aspx"><%# Eval("SectionName")%></a> </h3>
<p class="c66">浏览量:<%# Eval("HitTimes")%></p>
</div>
<div class="clear"></div>
<ul>
<asp:Repeater ID="RepBlogSectionsThreads" runat="server">
<ItemTemplate>
<li class="A_blog42"><a href="/u/<%# GetLoginName(Convert.ToInt32(Eval("OwnerUserID")))%>/Blog.aspx/t-<%# Eval("ThreadID") %>" target="_blank"><%# Eval("Subject")%> </a></li>
</ItemTemplate>
</asp:Repeater>
</ul>
</div>
</ItemTemplate>
</asp:Repeater>
</div>
cs代码:
View Code
protected void RepBlogSections_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Repeater rep = e.Item.FindControl("RepBlogSectionsThreads") as Repeater;//找到内嵌Repeater控件
DataRowView rowv = (DataRowView)e.Item.DataItem;//取得关联数据项
int userid = Convert.ToInt32(rowv["OwnerUserID"]);
rep.DataSource = btbll.GetList(2, "ThreadID,Subject,CommentCount,OwnerUserID", "OwnerUserID=" + userid, "PostDate desc");
rep.DataBind();
}
}