帮忙给个例子!
解决方案 »
- 这样的网站如何设计?
- 如何在我的动画gif图片上面加上水印
- 跪求两个正则式~!!!
- 在线等答案!!!!:调试ObjectDataSource控件时,出现未能找到带参数的非泛型方法
- 如何用asp.net实现歌曲下载
- 关于用javascript同三个系统同时登录、推出的问题
- Visual C#2005 Express Edition 做不了web开发?愣没找到创建web的工程文件。达人求教!
- 求助,在线等,关于不用滚动条使iframe页面滚动??
- 用户的个性化设计的数据库怎样设计?
- dropdownlist控件下拉框中的内容从数据库中帮定数据,当数据库中查询的结果为空的时候,需要判断.我用下面的方法提示出错@!哀
- 对 web 服务了解的朋友 请 指点 asp.net(c#)
- 大家讨论一下关于asp.net客户段支持的浏览器
上边有详细的例子,可以看看
http://www.microsoft.com/china/msdn/archives/library/workshop/webcontrols/overview/treeview.asp2.
引用:
http://community.csdn.net/Expert/topic/4196/4196863.xml?temp=9.365261E-03
http://community.csdn.net/Expert/topic/3169/3169028.xml?temp=.8414118
public static string ConnectionString=System.Configuration .ConfigurationSettings .AppSettings["ConnectionString"];
#region GetDataSet
public static DataSet GetDataSet(string sql)
{
SqlDataAdapter sda =new SqlDataAdapter(sql,ConnectionString);
DataSet ds=new DataSet();
sda.Fill(ds);
return ds;
}
#endregion
protected string LoadTree()
{
string sql="select * from "+DataBase;
DataSet ds=GetDataSet(sql);
string node="";
for(int m=0;m<ds.Tables[0].Rows.Count;m++)
{
node = node + " tree.nodes["+"\""+ ds.Tables[0].Rows[m]["parentId"].ToString()+"_"+ ds.Tables[0].Rows[m]["id"].ToString()+"\""+"] = ";
node = node + "\""+"text:"+ ds.Tables[0].Rows[m]["text"].ToString()+";";
node = node + "hint:"+ds.Tables[0].Rows[m]["hint"].ToString()+";";
node = node + "icon:"+ds.Tables[0].Rows[m]["icon"].ToString() +";";
node = node + "data:"+ds.Tables[0].Rows[m]["data"].ToString()+";";
node = node + "url:"+ds.Tables[0].Rows[m]["url"].ToString()+";";
node = node + "target:"+ ds.Tables[0].Rows[m]["target"].ToString() +";";
node = node + "method:"+ ds.Tables[0].Rows[m]["method"].ToString()+"\""+";";
}
return node;
}
--------------------------------
//前台调用
tree.setIconPath("http://www.meizz.com/Icons/TreeView/"); //可用相对路径
<%=LoadTree()%>//调用后台数据库方法,产生树
tree.setURL("default.aspx");
tree.setTarget("meng");
string sql="select * from "+DataBase;
改成
string sql="select * from DataBasename";//传入数据库表,如treeview