Private void bindtreeview ()
{
Unitinfo bunitinfo = new unitinfo ();
Dataset DS = bunitinfo. getunitinfo ();
If (Ds! = NULL & Ds. Tables [0]. Rows. Count> 0)
{
Bool hasaddedlast = true ;;
String strds = "<? XML version = '1. 0' encoding = 'gb2312 '?> ";
For (INT I = 1; I <Ds. Tables [0]. Rows. Count; I ++)
{
Strds + = "<a name = '" + Ds. tables [0]. rows [I-1] [1]. tostring () + "'tid = '" + Ds. tables [0]. rows [I-1] [0]. tostring () + "'> ";
For (Int J = I; j <Ds. Tables [0]. Rows. Count; j ++)
{
I = J;
If (Ds. tables [0]. rows [J-1] ["path"]. tostring (). length = Ds. tables [0]. rows [J] ["path"]. tostring (). length)
{
Strds + = "</a> <a name = '" + Ds. tables [0]. rows [J] [1]. tostring () + "'tid = '" + Ds. tables [0]. rows [J] [0]. tostring () + "'> ";
}
Else if (Ds. tables [0]. rows [J-1] ["path"]. tostring (). length <Ds. tables [0]. rows [J] ["path"]. tostring (). length)
{
Strds + = "<a name = '" + Ds. tables [0]. rows [J] [1]. tostring () + "'tid = '" + Ds. tables [0]. rows [J] [0]. tostring () + "'> ";
}
Else
{
If (I = Ds. Tables [0]. Rows. Count-1)
{
Hasaddedlast = false;
}
Break;
}
}
Int ncount = 0;
Ncount = system. math. ABS (Ds. tables [0]. rows [I-1] ["path"]. tostring (). length-Ds. tables [0]. rows [I] ["path"]. tostring (). length)/5 + 1;
For (Int J = 0; j <ncount; j ++)
{
Strds + = "</a> ";
}
If (I = Ds. Tables [0]. Rows. Count-1) & hasaddedlast = false)
{
Strds + = "<a name = '" + Ds. tables [0]. rows [I] [1]. tostring () + "'tid = '" + Ds. tables [0]. rows [I] [0]. tostring () + "'> ";
For (int K = 0; k <(Ds. tables [0]. rows [I] ["path"]. tostring (). length/5-1); k ++)
{
Strds + = "</a> ";
}
}
}
Strds + = "</a> ";
Xmldatasource xds = new xmldatasource ();
Xds. ID = "xds ";
Xds. Data = strds;
Treeview1.datasource = xds;
Treeview1.databind ();
}
}
ThisAlgorithmIt is not verified by a large amount of data!