A piece of code written using the Treeview control takes n long to come out.
Protected void treeview1_load ()
{
// Fill in treeview1
Sqlcommand mycommand1 = new sqlcommand ("select * from chapter where course_id = 0", myconn );
Sqldatareader DR1 = mycommand1.executereader ();
// Sqldataadapter da1 = new sqldataadapter (mycommand1 );
// Dataset ds1 = new dataset ("Temp ");
// Da1.fill (ds1 );
Sqlcommand mycommand2;
Sqldatareader DR2;
While (dr1.read ())
{
Treenode newnode = new treenode (DR1 ["chapter_name"]. tostring ());
Newnode. value = DR1 ["chapter_id"]. tostring ();
Newnode. Collapse ();
// L2 node --->
// Mycommand2 = new sqlcommand ("select * from section where chapter_id =" + DR1 ["chapter_id"]. tostring (), myconn );
// DR2 = mycommand2.executereader ();
// Treenode newnode2 = new treenode (DR2 ["section_name"]. tostring ());
// Newnode. childnodes. Add (newnode2 );
// <-----
Treeview1.nodes. Add (newnode );
}
Dr1.close ();
Foreach (treenode newnode in treeview1.nodes)
{
Mycommand2 = new sqlcommand ("select * from section where chapter_id =" + newnode. value. tostring (), myconn );
DR2 = mycommand2.executereader ();
While (dr2.read ())
{
Treenode tempnode = new treenode (DR2 ["section_name"]. tostring ());
Tempnode. navigateurl = "#";
Tempnode. Target = "_ blank ";
Newnode. childnodes. Add (tempnode );
}
Dr2.close ();
}
/*
If (ds1.tables ["chapter"]. Rows. Count. compareto (0)> 0)
{
Foreach (datarow row in ds1.tables ["chapter"]. Rows)
{
Treenode newnode = new treenode (row ["chapter_name"]. tostring ());
// L2 node --->
Mycommand2 = new sqlcommand ("select * from section where chapter_id =" + row ["chapter_name"]. tostring (), myconn );
DR2 = mycommand2.executereader ();
Treenode newnode2 = new treenode (DR2 ["section_name"]. tostring ());
Newnode. childnodes. Add (newnode2 );
// <---------
Treeview1.nodes. Add (newnode );
}
}
Ds1.dispose ();
*/
}