前台代码:
![ContractedBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
<
asp:Repeater ID
=
"
Repeater1
"
runat
=
"
server
"
>
< HeaderTemplate >
< table border = " 0 " align = " center " cellpadding = " 3 " cellspacing = " 1 " class = " table_b " >
< tr >
< td width = " 30 " class = " title_bg " > ID </ td >
< td class = " title_bg " > 名称 </ td >
< td class = " title_bg " > 排序 </ td >
< td class = " title_bg " > 管理 </ td >
</ tr >
</ HeaderTemplate >
< ItemTemplate >
<% #((DataRowView)Container.DataItem)[ " Colum " ] %>
</ ItemTemplate >
< FooterTemplate >
</ table >
</ FooterTemplate >
</ asp:Repeater >
< HeaderTemplate >
< table border = " 0 " align = " center " cellpadding = " 3 " cellspacing = " 1 " class = " table_b " >
< tr >
< td width = " 30 " class = " title_bg " > ID </ td >
< td class = " title_bg " > 名称 </ td >
< td class = " title_bg " > 排序 </ td >
< td class = " title_bg " > 管理 </ td >
</ tr >
</ HeaderTemplate >
< ItemTemplate >
<% #((DataRowView)Container.DataItem)[ " Colum " ] %>
</ ItemTemplate >
< FooterTemplate >
</ table >
</ FooterTemplate >
</ asp:Repeater >
![ContractedBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
public
void
ListControl_Bind(
int
n)
{
Cy.BLL.Class bll_Class = new Cy.BLL.Class();
DataTable dt = bll_Class.GetList( " followid=0 " ).Tables[ 0 ];
dt.Columns.Add( " Operate " , typeof ( string )); // 操作
dt.Columns.Add( " Colum " , typeof (String)); // 在dt中增加字段名为Colum的列
if (dt.Rows.Count > 0 )
{
for ( int i = 0 ; i < dt.Rows.Count; i ++ )
{
DataRow dr = dt.Rows[i];
string strchar = "" ;
dr[ " operate " ] = " <a href=' " + dr[ " id " ].ToString() + " '>添加下级分类</a> <a href=''>编辑</a> <a href='' οnclick='return confirm(\ " 真的要删除 ? 不可恢复 ! \ " );'>删除</a> <a href='?action=sc&&classid = " + dr[ " id " ].ToString() + " '>生成</a> " ;
strchar += " <tr οnmοuseοver=this.bgColor='#EBFFDC'; οnmοuseοut=this.bgColor='#ffffff'; bgcolor='#ffffff'> " ;
strchar += " <td align=\ " center\ " > " + dr[ " id " ].ToString() + " </td> " ;
strchar += " <td align=\ " left\ " > " + dr[ " title " ].ToString() + " </td> " ;
strchar += " <td align=\ " center\ " height=\ " 25 \ " >上升 下降</td> " ;
strchar += " <td align=\ " center\ " > " + dr[ " Operate " ].ToString() + " </td> " ;
strchar += " </tr> " ;
Cy.BLL.Class bll_Classq = new Cy.BLL.Class();
strchar = InitChild(dr, strchar, bll_Classq, 2 );
dr[ " Colum " ] = strchar;
}
}
Repeater1.DataSource = dt;
Repeater1.DataBind();
}
private string InitChild(DataRow dr, string strchar, Cy.BLL.Class bll_Classq, int n)
{
DataTable dtt = bll_Classq.GetList( " followid=' " + dr[ " id " ] + " ' " ).Tables[ 0 ];
dtt.Columns.Add( " Operate " , typeof ( string ));
dtt.Columns.Add( " Colum " , typeof (String));
if (dtt.Rows.Count > 0 )
{
string s = " " ;
for ( int j = 1 ; j <= n; j ++ )
{
s += " " ;
}
for ( int k = 0 ; k < dtt.Rows.Count; k ++ )
{
DataRow dro = dtt.Rows[k];
string flag = " ├ " ;
if (dtt.Rows.Count == 1 )
{
flag = " ├ " ;
}
else
{
if (k == 0 )
{
flag = " ┌ " ;
}
if (k == dtt.Rows.Count - 1 )
{
flag = " └ " ;
}
}
dro[ " operate " ] = " <a href=' " + dro[ " id " ].ToString() + " '>添加下级分类</a> <a href=''>编辑</a> <a href='' οnclick='return confirm(\ " 真的要删除 ? 不可恢复 ! \ " );'>删除</a> <a href='?action=sc&&classid = " + dro[ " id " ].ToString() + " '>生成</a> " ;
strchar += " <tr οnmοuseοver=this.bgColor='#EBFFDC'; οnmοuseοut=this.bgColor='#ffffff'; bgcolor='#ffffff'> " ;
strchar += " <td align=\ " center\ " > " + dro[ " id " ].ToString() + " </td> " ;
strchar += " <td align=\ " left\ " > " + s + flag + dro[ " title " ].ToString() + " </td> " ;
strchar += " <td align=\ " center\ " height=\ " 25 \ " >上升 下降</td> " ;
strchar += " <td align=\ " center\ " > " + dro[ " Operate " ].ToString() + " </td> " ;
strchar += " </tr> " ;
strchar = InitChild(dro, strchar, bll_Classq, n + 8 );
}
}
return strchar;
}
{
Cy.BLL.Class bll_Class = new Cy.BLL.Class();
DataTable dt = bll_Class.GetList( " followid=0 " ).Tables[ 0 ];
dt.Columns.Add( " Operate " , typeof ( string )); // 操作
dt.Columns.Add( " Colum " , typeof (String)); // 在dt中增加字段名为Colum的列
if (dt.Rows.Count > 0 )
{
for ( int i = 0 ; i < dt.Rows.Count; i ++ )
{
DataRow dr = dt.Rows[i];
string strchar = "" ;
dr[ " operate " ] = " <a href=' " + dr[ " id " ].ToString() + " '>添加下级分类</a> <a href=''>编辑</a> <a href='' οnclick='return confirm(\ " 真的要删除 ? 不可恢复 ! \ " );'>删除</a> <a href='?action=sc&&classid = " + dr[ " id " ].ToString() + " '>生成</a> " ;
strchar += " <tr οnmοuseοver=this.bgColor='#EBFFDC'; οnmοuseοut=this.bgColor='#ffffff'; bgcolor='#ffffff'> " ;
strchar += " <td align=\ " center\ " > " + dr[ " id " ].ToString() + " </td> " ;
strchar += " <td align=\ " left\ " > " + dr[ " title " ].ToString() + " </td> " ;
strchar += " <td align=\ " center\ " height=\ " 25 \ " >上升 下降</td> " ;
strchar += " <td align=\ " center\ " > " + dr[ " Operate " ].ToString() + " </td> " ;
strchar += " </tr> " ;
Cy.BLL.Class bll_Classq = new Cy.BLL.Class();
strchar = InitChild(dr, strchar, bll_Classq, 2 );
dr[ " Colum " ] = strchar;
}
}
Repeater1.DataSource = dt;
Repeater1.DataBind();
}
private string InitChild(DataRow dr, string strchar, Cy.BLL.Class bll_Classq, int n)
{
DataTable dtt = bll_Classq.GetList( " followid=' " + dr[ " id " ] + " ' " ).Tables[ 0 ];
dtt.Columns.Add( " Operate " , typeof ( string ));
dtt.Columns.Add( " Colum " , typeof (String));
if (dtt.Rows.Count > 0 )
{
string s = " " ;
for ( int j = 1 ; j <= n; j ++ )
{
s += " " ;
}
for ( int k = 0 ; k < dtt.Rows.Count; k ++ )
{
DataRow dro = dtt.Rows[k];
string flag = " ├ " ;
if (dtt.Rows.Count == 1 )
{
flag = " ├ " ;
}
else
{
if (k == 0 )
{
flag = " ┌ " ;
}
if (k == dtt.Rows.Count - 1 )
{
flag = " └ " ;
}
}
dro[ " operate " ] = " <a href=' " + dro[ " id " ].ToString() + " '>添加下级分类</a> <a href=''>编辑</a> <a href='' οnclick='return confirm(\ " 真的要删除 ? 不可恢复 ! \ " );'>删除</a> <a href='?action=sc&&classid = " + dro[ " id " ].ToString() + " '>生成</a> " ;
strchar += " <tr οnmοuseοver=this.bgColor='#EBFFDC'; οnmοuseοut=this.bgColor='#ffffff'; bgcolor='#ffffff'> " ;
strchar += " <td align=\ " center\ " > " + dro[ " id " ].ToString() + " </td> " ;
strchar += " <td align=\ " left\ " > " + s + flag + dro[ " title " ].ToString() + " </td> " ;
strchar += " <td align=\ " center\ " height=\ " 25 \ " >上升 下降</td> " ;
strchar += " <td align=\ " center\ " > " + dro[ " Operate " ].ToString() + " </td> " ;
strchar += " </tr> " ;
strchar = InitChild(dro, strchar, bll_Classq, n + 8 );
}
}
return strchar;
}