asp.net带的TreeView有几个缺点:
1,有的浏览器不能够正确显示树,就是ie6有的也不能够正常显示
2,速度慢,老牛拉破车啊,慢的不得了
所以我就找了个js树,数据库版的,但那是asp的,没办法,把他改成aspx的吧!!!
梅花树的资料:开发文档: http://www.meizz.com/Web/Article.asp?id=436
控件下载: http://www.meizz.com/Web/Download/MzTreeView10.rar
应用示例: http://www.meizz.com/Web/Demo/MzTreeView10.htm
更多细节:http://community.csdn.net/Expert/topic/3841/3841740.xml?temp=.3988459
特别感谢:久久的宝贝!!!!!
left.aspx代码如下:
现在是后台cs文件:
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
{
///
/// left 的摘要说明。
///
public class left : System.Web.UI.Page
{
public string str;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
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();
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
///
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
///
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
存储过程很简单:
create proc select_treeview_pwqzc
as
select * from treeview order by ID
go