Data | database
The treeview of the ASP.net belt has several drawbacks:
1, some browsers can not correctly display the tree, is IE6 some also can not be normal display
2, slow, old cow pull a broken car ah, very slow
So I found a JS tree, database version, but that is ASP, there is no way to change him into an ASPX bar!!!
Plum Tree Data: Development document: http://www.meizz.com/Web/Article.asp?id=436
Control Download: Http://www.meizz.com/Web/Download/MzTreeView10.rar
Application Example: http://www.meizz.com/Web/Demo/MzTreeView10.htm
More details: http://community.csdn.net/Expert/topic/3841/3841740.xml?temp=.3988459
Special thanks: a long time baby!!!!!
The left.aspx code is as follows:
<script language= "JavaScript" src= "Mztreeview10.js" ></script>
<link href= "Menutree/menu.css" type= "Text/css" rel= "stylesheet" >
<style> A.mztreeview {padding-left:3px; FONT-SIZE:12PX} </style>
</HEAD>
<body leftmargin= "0" topmargin= "2" >
<script language= "JavaScript" >
Window.tree = new Mztreeview ("Tree");
Tree.seticonpath ("menutree/"); Available relative paths
<%=str%>//STR Here is a string defined in the background, he contains all the node information from the database, can only write here
Tree.seturl ("catalog.asp");
Tree.settarget ("Mzmain");
document.write (Tree.tostring ()); can also use obj.innerhtml = Tree.tostring ();
Tree.focus (111); Let the node with ID 111 get the focus, and also expand the parent node on this node!
-->
</SCRIPT>
</body>
Now is the background CS file:
Using System;
Using System.Collections;
Using System.ComponentModel;
Using System.Data;
Using System.Drawing;
Using System.Web;
Using System.Web.SessionState;
Using System.Web.UI;
Using System.Web.UI.WebControls;
Using System.Web.UI.HtmlControls;
Namespace Hualong.bbs
{
<summary>
A summary description of left.
</summary>
public class Left:System.Web.UI.Page
{
public string str;
private void Page_Load (object sender, System.EventArgs e)
{
Place user code here to initialize page
String connectstring = system.configuration.configurationsettings.appsettings["ConnStr1"]. ToString ();
System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection (connectstring);
System.Data.SqlClient.SqlDataAdapter adapter = new System.Data.SqlClient.SqlDataAdapter ("Select_treeview_pwqzc", conn);
Try
{
System.Text.StringBuilder node = new System.Text.StringBuilder ();
Conn. Open ();
System.Data.DataSet DataSet = new System.Data.DataSet ();
DataSet. Tables.add ("TreeView");
Adapter. Fill (DataSet, "TreeView");
foreach (System.Data.DataRow row in DataSet. Tables[0]. Rows)
{
Node. Append ("\ r \ n tree.nodes[\" "+ row[" ParentID "]. ToString () + "_" + row["id"] + "\"] = \ "");
Node. Append ("text:" + row["text"]. ToString (). Replace ("\0xe", ";") + ";");
Node. Append (row["hint"]!= dbnull.value && row["hint"]. ToString ()!= string. Empty? "Hint:" + row["hint"]. ToString (). Replace ("\0xe", ";") + ";": String. Empty);
Node. Append (row["icon"]!= dbnull.value && row["icon"]. ToString ()!= string. Empty? "Icon:" + row["icon"]. ToString (). Replace ("\0xe", ";") + ";": String. Empty);
Node. Append (row["Data"]!= dbnull.value && row["Data"]. ToString ()!= string. Empty? "Data:" + row["data"]. ToString (). Replace ("\0xe", ";") +server.urlencode (row["text"). ToString ()) + ";": String. Empty);
Node. Append (row["url"]!= dbnull.value && row["url"]. ToString ()!= string. Empty? "URL:" + row["url"]. ToString (). Replace ("\0xe", ";") + ";": String. Empty);
Node. Append (row["target"]!= dbnull.value && row["target". ToString ()!= string. Empty? "Target:" + row["target"]. ToString (). Replace ("\0xe", ";") + ";": String. Empty);
Node. Append (row["method")!= DBNull.Value && row["method"]. ToString ()!= string. Empty? ' Method: ' + row[' method ']. ToString (). Replace ("\0xe", ";") + ";": String. Empty);
Node. Append ("\");
}
str = node. ToString ();
DataSet. Dispose ();
}
Finally
{
Conn. Close ();
}
}
Code generated #region the Web forms Designer
Override protected void OnInit (EventArgs e)
{
//
CodeGen: This call is required for the ASP.net Web forms Designer.
//
InitializeComponent ();
Base. OnInit (e);
}
<summary>
Designer supports required methods-do not use the Code editor to modify
The contents of this method.
</summary>
private void InitializeComponent ()
{
This. Load + = new System.EventHandler (this. Page_Load);
}
#endregion
}
}
Stored procedures are simple:
Create proc SELECT_TREEVIEW_PWQZC
As
SELECT * from TreeView ORDER by ID
Go