The following section describes how to use the temporary view function to implement the treeview, but not the data that has not been added to the SQL view.
Protected void Page_Load (object sender, EventArgs e)
{
This. TreeView1.Nodes. Clear (); // Clear all vertices of the treeview first
Maketree (); // generate a treeview
TreeView1.DataBind (); // set data size
}
Protected void maketree ()
{
TreeNode RootNode; // defines a pixel
For (int I = 0; I <10; I ++) // generates 10 root nodes first.
{
RootNode = new TreeNode (); // The actual instance represents a mirror;
RootNode. Text = "root vertex" + I. ToString (); // you can specify a vertex to display file information.
RootNode. Value = I. ToString (); // set the vertex Value
This. TreeView1.Nodes. Add (RootNode); // Add the vertex to the TreeView control.
MakeChildNode
}
}
Protected void MakeChildNode (TreeNode tn, int ParentID)
{
TreeNode CHildNode;
For (int I = 0; I <ParentID; I ++)
{
CHildNode = new TreeNode ("sub-vertex" + I. ToString (), I. ToString ());
Tn. ChildNodes. Add (CHildNode );
// MakeChildNode (CHildNode, I); // the error message returned when the error message returned, before using the metric, determine whether there is a downstream metric at the specific metric point, or control the number of metric data.
}
}
Which of the following is a problematic generation? Too many ........
Protected void TV _binder ()
{
SqlConnection conn = DB. createConection ();
SqlCommand cmd = new SqlCommand ("select * from Dep", conn );
SqlDataAdapter adp = new SqlDataAdapter (cmd );
DataSet ds = new DataSet ();
Adp. Fill (ds, "Dep ");
Cmd. CommandText = "select * from Class ";
Adp = new SqlDataAdapter (cmd );
Adp. Fill (ds, "Class ");
If (ds. Tables ["Dep"]. Rows. Count> 0)
{
For (int I = 0; I <ds. Tables ["Dep"]. Rows. Count; I ++)
{// Insert the primary SQL statement into the primary SQL statement
TreeNode tn = new TreeNode ();
Tn. Text = ds. Tables ["Dep"]. Rows [I] ["DepthName"]. ToString ();
Tn. NavigateUrl = "NavMenu. aspx? Act = list & Dep = "+ ds. Tables [" Dep "]. Rows [I] [" DepID "]. ToString ();
This. TV _leftmenu.Nodes.Add (tn );
TV _ChildTreeNode (Convert. toInt32 (ds. tables ["Dep"]. rows [I] ["DepID"]. toString (), tn, ds. tables ["Class"]);
}
}
This. TV _treeview.DataBind ();
}
Protected void TV _ChildTreeNode (int DepID, TreeNode tn, DataTable dt)
{
Dt. DefaultView. RowFilter = "DepID ";
DataView dv = dt. DefaultView;
Adp. Fill (ds );
If (dv. Count> 0)
{
For (DataRowView drv in dv)
{// Insert the primary SQL statement into the primary SQL statement
TreeNode Child_tn = new TreeNode ();
Child_tn.Text = drv ["ClassName"]. ToString ();
Child_tn.NavigateUrl = "NavMenu. aspx? Act = list & Dep = "+ drv [" DepID "]. ToString ();
Tn. ChildNodes. Add (Child_tn );
TV _ChildTreeNode (Convert. ToInt32 (drv ["DepID"]. ToString (), Child_tn, dt );
}
}
}