CopyCode The Code is as follows: Private datatable gettable (INT topid)
{
Datatable dt = NULL;
Try
{
String constr = "Server =.; database = tqnpc; uid = sa; Pwd = sa ";
String selstr = "select * From RW _ working relationship where main_id =" + topid + "";
Sqlconnection con = new sqlconnection (constr );
Sqldataadapter da = new sqldataadapter (selstr, con );
Dt = new datatable ();
Da. Fill (DT );
}
Catch (exception ex)
{
Response. Write (ex. Message );
}
Return DT;
}
Protected void maketree ()
{
Datatable dt = gettable (0 );
Try
{
If (DT! = NULL)
{
For (INT I = 0; I <DT. Rows. Count; I ++)
{
Treenode Tn = new treenode ();
Tn. Text = DT. Rows [I] ["main_id"]. tostring ();
Tn. value = DT. Rows [I] ["ref_id"]. tostring ();
Tn. selectaction = treenodeselectaction. Select;
Treeview1.nodes. Add (TN );
Addtreenodes (Int. parse (DT. rows [I] ["ref_id"]. tostring (), Int. parse (DT. rows [I] ["ref_id"]. tostring (), TN );
}
}
}
Catch (exception ex)
{
Response. Write (ex. Message );
}
}
This method also has certain requirements on the database structure. The database design is as follows: