Thank you for helping me do the test.
Demo
[Url = Response
Download the required JS and CSS files from my resources.
Create Table bbs_panel1 in step 1
Id panelname panelmsg URL
21. development language xx
Table bbs_panel2
Id PID panelname panelinfo panelsort URL
1 21 VC/MFC
2 21 VB
Table bbs_panel3
Id PID ppid panelname panelinfo panelsort URL
1 1 21 basic classes
2 1 21 Interfaces
3 1 21 Network Programming
Step 2 nesting Repeater
[Code = HTML]
<Head runat = "server">
<Title> treeleft </title>
<LINK rel = "stylesheet" href = "JS/jquery.treeview.css"/>
<LINK rel = "stylesheet" href = "JS/red-treeview.css"/>
<LINK rel = "stylesheet" href = "JS/screen.css"/>
<SCRIPT src = "JS/jquery. js" type = "text/JavaScript"> </SCRIPT>
<SCRIPT src = "JS/jquery. Cookie. js" type = "text/JavaScript"> </SCRIPT>
<SCRIPT src = "JS/jquery. Treeview. js" type = "text/JavaScript"> </SCRIPT>
<SCRIPT type = "text/JavaScript">
$ (Function (){
$ ("# Tree"). Treeview ({
Collapsed: True,
Animated: "medium ",
Control: "# sidetreecontrol ",
Persist: "location"
});
})
$ (Document). Ready (
Function ()
{
Delclass ();
});
Function delclass ()
{
VaR Lis = Document. getelementsbytagname ('lil ');
VaR I;
VaR length;
For (I = 0; I <length; I ++)
{
If (LIS [I]. getelementsbytagname ('ul '). Length = 0)
{
Lis [I]. setattribute ('class ','');
}
}
}
</SCRIPT>
</Head>
<Body>
<Div id = "Main"> <a href = "#"> </a>
<Div id = "sidetree">
<Div id = "sidetreecontrol"> <a href = "#"> collapse all </a> | <a href = "#"> Expand All </a> </Div>
<Ul id = "Tree" class = "Treeview">
<Asp: repeater id = "bclass" runat = "server" onitemdatabound = "bclasslist">
<Itemtemplate>
<Li class = "expandable"> <Div class = "hitarea expandable-hitarea"> </div> <a href = "title. aspx? Mode = 1 & id = <% # eval ("ID") %> "target =" Main "> <strong> <% # eval (" menuname ") %> </strong> </a>
<Ul style = "display: none;"> <asp: repeater id = "bsclass" runat = "server" onitemdatabound = "bsclasslist"> <itemtemplate>
<Li class = "expandable"> <a href = "title. aspx? Mode = 2 & id = <% # eval ("PID") %> & pid = <% # eval ("ID ") %> "target =" Main "> <% # eval (" menuname ") %> </a>
<Ul style = "display: none;"> <asp: repeater id = "sclass" runat = "server"> <itemtemplate> <li> <a href = "title. aspx? Mode = 3 & id = <% # eval ("ppid") %> & pid = <% # eval ("PID ") %> & ppid = <% # eval ("ID") %> "target =" Main "> <% # eval (" menuname ") %> </a> </LI>
</Itemtemplate> </ASP: repeater>
</Ul>
</LI>
</Itemtemplate> </ASP: repeater>
</Ul>
</LI>
</Itemtemplate>
</ASP: repeater>
</Ul>
<Br style = "clear: Left"/>
</Div>
</Div>
</Body>
[/Code]
Step 3 Background
[Code = C #]
Private string strbbstype = "2 ";
Private string SQL = "";
Protected void page_load (Object sender, eventargs E)
{
If (request. querystring ["bbstype"]! = NULL)
{
Strbbstype = request. querystring ["bbstype"]. tostring ();
}
If (! Ispostback)
{
If (strbbstype = "1 ")
{
SQL = "select ID, menuname, URL from m_menuhead where ID> 0 order by ID ";
}
Else
{
SQL = "select ID, panelname as menuname, URL from bbs_panel1 ";
}
Dataset RD = new dataset ();
RD = sqlhelper. executedataset (sqlhelper. conn2, commandtype. Text, SQL );
Bclass. datasource = RD;
Bclass. databind ();
}
}
Protected void bclasslist (Object sender, repeateritemeventargs E)
{
If (E. Item. itemtype = listitemtype. Item | E. Item. itemtype = listitemtype. alternatingitem)
{
String preid = (datarowview) E. Item. dataitem). Row ["ID"]. tostring (); // obtain the corresponding ID
Repeater bsclass = (repeater) E. Item. findcontrol ("bsclass"); // locate the repeater to bind data
If (bsclass! = NULL)
{
If (strbbstype = "1 ")
{
SQL = "select ID, PID, menuname from m_menuchildren where pid =" + preid + "";
}
Else
{
SQL = "select ID, PID, panelname as menuname from bbs_panel2 where pid =" + preid + "";
}
Dataset SRD = new dataset ();
SRD = sqlhelper. executedataset (sqlhelper. conn2, commandtype. Text, SQL );
Bsclass. datasource = SRD;
Bsclass. databind ();
}
}
}
Protected void bsclasslist (Object sender, repeateritemeventargs E)
{
If (E. Item. itemtype = listitemtype. Item | E. Item. itemtype = listitemtype. alternatingitem)
{
String preid = (datarowview) E. Item. dataitem). Row ["ID"]. tostring (); // obtain the corresponding ID
Repeater sclass = (repeater) E. Item. findcontrol ("sclass"); // locate the repeater to bind data
If (sclass! = NULL)
{If (strbbstype = "1 ")
{
SQL = "select ID, PID, ppid, menuname from m_menuchildren2 where pid =" + preid + "";
}
Else
{
SQL = "select ID, PID, ppid, panelname as menuname from bbs_panel3 where pid =" + preid + "";
}
Dataset SRD = new dataset ();
SRD = sqlhelper. executedataset (sqlhelper. conn2, commandtype. Text, SQL );
// Sqlhelper. conn2 is the database connection character
Sclass. datasource = SRD;
Sclass. databind ();
}
}
}
[/Code]