Using System;
Using System. Collections. Generic;
Using System. LINQ;
Using System. Web;
Using System. Web. UI;
Using System. Web. UI. webcontrols;
Using QHR. qhrservice;
Namespace QHR
{
Public Partial Class Test : System. Web. UI.Page
{
QHR. qhrservice. qhrserviceclient proxy = New qhrservice. qhrserviceclient ();
Qhrservice.Myprotocolstructurecollection Collection = Null;
Protected Void Page_load(Object Sender,Eventargs E)
{
If(! Ispostback)
{
Collection = Proxy. getallprotocolstructure();
Loadtree();
}
}
Private Void Loadtree()
{
This. Treeview1.nodes. Clear();
Inittree(This. Treeview1.nodes,Null);
}
private void inittree ( treenodecollection NDS , string parentid )
{
Treenode Tmpnd = Null;
myprotocolstructurecollection collectiontemp = New myprotocolstructurecollection ();
foreach ( myprotocolstructure pstemp in collection )
{
If(Pstemp. PID = Parentid)
{
Collectiontemp. Add(Pstemp);
}
}
foreach ( myprotocolstructure ps in collectiontemp )
{
Tmpnd = New Treenode();
Tmpnd. Text = PS. Name;
Tmpnd. Value = PS. ID;
If(Parentid = Null)
{
Tmpnd. Expanded = True;
}
Else
{
Tmpnd. Expanded = False;
}
NDS. Add(Tmpnd);
Inittree(NDS[NDS. Count - 1]. Childnodes,PS. ID);
}
}
}
}