关于梅花雪树形控件2.0的问题
我在中使用了梅花雪大哥的TreeView 2.0版的。想实现从后台数据库读出数据然后生成树,现在数据都读出了,可就是树不出来,页面显示的是no data,可是我是有数据的呀。还请大家帮忙解答下,谢谢 后台代码:
public partial class Admin_test_test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public string LoadTree()
{
InfoVillage.BLL.IV_Area bll_Area = new InfoVillage.BLL.IV_Area();
string nodes = "";
DataSet ds = bll_Area.GetAllList();
nodes = "var data = {};";
foreach(DataRow dr in ds.Tables[0].Rows)
{
if (dr["areaID"].ToString().Length == 2)
{
nodes += "data[\"00_" + dr["areaID"].ToString() + "\"] = \"text:" + dr["areaName"].ToString() + ";\";\r\n";
}
else if (dr["areaID"].ToString().Length == 4 ? ? dr["areaID"].ToString().Length == 6)
{
nodes += "data[\'" + dr["parentID"].ToString() + "_" + dr["areaID"].ToString() + "\'] = \'text:" + dr["areaName"].ToString() + ";\';\r\n";
}
}
nodes += "Using(\"System.Web.UI.WebControls.MzTreeView\");";
nodes += "var a = new MzTreeView();";
nodes += "a.dataSource = data;";
nodes += "a.setJsDataPath(\"csdn/community/treedata/\");";
nodes += "a.setXmlDataPath(\"csdn/community/treedata/\");";
//a.rootId="1";
nodes += "a.autoSort=false;";
nodes += "a.useCheckbox=true;";
nodes += "a.canOperate = true;";
nodes += "document.write(a.render());";
nodes += "a.expandLevel(1);";
return nodes;
true);
}
}
前台代码:
<%@ Page language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="Admin_test_test" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www. >
<head runat="server">
<title>无标题页 </title>
<script language="javascript" type="text/javascript" src="jsframework.js"> </script>
</head>
<body>
<form id="form1" runat="server">
<script language="javascript" type="text/javascript">
<%=LoadTree() %>
</script>
</form>
</body>
</html>