<asp:Repeater ID="Repeater1" runat="server"
onitemdatabound="Repeater1_ItemDataBound">
<ItemTemplate>
<tr><td>
<span style="width:168px;" class="Prent"><%#Eval("name")%></span>
</td></tr> <tr class="Hover" ><td class="Hover" >
<asp:Repeater ID="Repeater2" runat="server" OnItemCommand="Repeater2_ItemCommand" onitemdatabound="Repeater2_ItemDataBound">
<ItemTemplate>
<span class="Hover" style="vertical-align:bottom; line-height:20px;"><asp:ImageButton ID="ImageButton1" runat="server" /> <a target="_blank" href="/bbs/showforum.aspx?forumid=<%# Eval("fid")%>">2<%#Eval("name")%></a></span>
<br />
<asp:Repeater ID="Repeater3" runat="server">
<ItemTemplate>
<span class="Hover" style="vertical-align:bottom; line-height:20px;"><a target="_blank" href="/bbs/showforum.aspx?forumid=<%# Eval("fid")%>">3<%#Eval("name")%><img id="Img1" style="border:0px;" alt="" runat="server" src="/TreeLineImages/smallpic.gif" /></a></span>
<br />
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
<asp:Repeater ID="Repeater1" runat="server"
onitemdatabound="Repeater1_ItemDataBound">
<ItemTemplate>
<tr><td>
<span style="width:168px;" class="Prent"><%#Eval("name")%></span>
</td></tr> <tr class="Hover" ><td class="Hover" >
<asp:Repeater ID="Repeater2" runat="server" OnItemCommand="Repeater2_ItemCommand" onitemdatabound="Repeater2_ItemDataBound">
<ItemTemplate>
<span class="Hover" style="vertical-align:bottom; line-height:20px;"><asp:ImageButton ID="ImageButton1" runat="server" /> <a target="_blank" href="/bbs/showforum.aspx?forumid=<%# Eval("fid")%>">2<%#Eval("name")%></a></span>
<br />
<asp:Repeater ID="Repeater3" runat="server">
<ItemTemplate>
<span class="Hover" style="vertical-align:bottom; line-height:20px;"><a target="_blank" href="/bbs/showforum.aspx?forumid=<%# Eval("fid")%>">3<%#Eval("name")%><img id="Img1" style="border:0px;" alt="" runat="server" src="/TreeLineImages/smallpic.gif" /></a></span>
<br />
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>cs:
view plaincopy to clipboardprint?
protected void Page_Load(object sender, EventArgs e)
{
string sql;
if (!Page.IsPostBack)
{
sql="select * from dnt_forums where layer=0";
access_data.bind_data(sql, this.Repeater1);
}
}
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Repeater subRep = (Repeater)e.Item.FindControl("Repeater2");
DataRowView dr = (DataRowView)e.Item.DataItem;
int Perentid = Convert.ToInt32(dr["fid"]);
data.bind_data("select *from dnt_forums where parentid=" + Perentid, subRep);
}
}
protected void Repeater2_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Repeater subRepA = (Repeater)e.Item.FindControl("Repeater3");
ImageButton Img = (ImageButton)e.Item.FindControl("ImageButton1");
DataRowView drA = (DataRowView)e.Item.DataItem;
int Perentid = Convert.ToInt32(drA["fid"]);
data.bind_data("select *from dnt_forums where parentid=" + Perentid, subRepA);
if (subRepA.Items.Count==0)
{
Img.ImageUrl = "~/TreeLineImages/lminus.gif";
}
else
{
Img.ImageUrl = "~/TreeLineImages/plus.gif";
subRepA.Visible = false;
}
}
}
protected void Repeater2_ItemCommand(object source, RepeaterCommandEventArgs e)
{
Repeater subRepA = (Repeater)e.Item.FindControl("Repeater3");
ImageButton Img = (ImageButton)e.Item.FindControl("ImageButton1");
if (subRepA.Visible)
{
Img.ImageUrl = "~/TreeLineImages/plus.gif";
subRepA.Visible = false;
}
else
{
Img.ImageUrl = "~/TreeLineImages/minus.gif";
subRepA.Visible = true;
}
}
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/XJY123/archive/2008/07/04/2612207.aspx