<asp:Repeater ID="rpt1" runat="server" OnItemDataBound="rptContent_ItemDataBound">
<ItemTemplate>
<h3 class="h3">
<a href="<%#Eval("......") %>" title="<%#Eval(".......") %>" target="_blank"><%#Eval(".........") %></a>
<ul class="ul" style="display: none">
<asp:Repeater ID="rpt2" runat="server">
<ItemTemplate>
<li><a href="<%#Eval(".......")%>" target="_blank"> <%#Eval("......") %></a></li>
</ItemTemplate>
</asp:Repeater>
</ul>
</h3>
</ItemTemplate>
</asp:Repeater>
</div>
后台方法:
protected void rptContent_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
//1\获取当前的数据源
DataRowView rv = (DataRowView)e.Item.DataItem;
//2\查找里面的子控件
Repeater rpt2 = (Repeater)e.Item.FindControl("rpt2");
int id = rv["ID"];
DataTable dt = BLL.GetDT();//读取数据
//5>判断DT是否为空,如果不为空,则绑定到Repeater控件
if (dt.Rows.Count > 0)
{
rpt2.DataSource = dt;
rpt2.DataBind();
}
}
}