treeview不限级别无限循环栏目 要实现如图上面的功能,其中每个栏目都能添加子类,并且没有限制的,能无限添加。 之前用了treeview只是拖出来界面写死的,查了一些看的绑定的也都有级别限制,不能无限绑,添加倒是没什么,就是把这些都绑到前面显示的时候这个循环不知道怎么弄。求助~ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这个tree估计是要自己写了,自己实现这些功能 gridview,repeater中嵌入treeviewhttp://topic.csdn.net/u/20100719/10/6ad767ee-b192-4e86-ac31-737c192020f5.html Tree绑定就用递归,但是,增删改你就自己写呀,这是最好的方法啊 这几天打断了,弄了点别的,现在又回头重新弄。找了个http://apps.hi.baidu.com/share/detail/2240056 仿照他这个来写。但是到这一步tn.PopulateOnDemand = (Convert.ToInt32(dr["childnodecount"]) > 0 ? true : false); 我这一字段的确大于0,但是始终为false,很郁闷,不知道怎么回事。这是我前台的页面:<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="class.aspx.cs" Inherits="xx.Admin.news._class" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title> <link href="../Style/all.css" rel="stylesheet" type="text/css" /></head><body> <form id="form1" runat="server"> <div style="text-align: center;"> <asp:TreeView ID="tk" runat="server" ShowLines="true" ShowExpandCollapse="true" OnTreeNodePopulate="tk_TreeNodePopulate"> </asp:TreeView> </div> </form></body></html>这个是后台的 public partial class _class : System.Web.UI.Page { protected int i=0; protected string s; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindRoot(); } } protected void BindRoot() { DataTable root = getTable(s_sql(0)); BindNode(root, tk.Nodes); } protected void BindSub(int parent_id, TreeNode parent_node) { DataTable sub = getTable(s_sql(parent_id)); BindNode(sub, parent_node.ChildNodes); } protected void tk_TreeNodePopulate(object sender, TreeNodeEventArgs e) { BindSub(Convert.ToInt32(e.Node.Value), e.Node); } private void BindNode(DataTable dt, TreeNodeCollection nodes) { foreach (DataRow dr in dt.Rows) { TreeNode tn = new TreeNode(); tn.Text = dr["Name"].ToString(); tn.Value = dr["NK_ID"].ToString(); nodes.Add(tn); tn.PopulateOnDemand =( Convert.ToInt32(dr["PID"]) > 0 ? true : false); tn.SelectAction = TreeNodeSelectAction.Expand; } } protected static string s_sql(int id) { string s=string.Empty; return s= "select * from TBNewsKind where PID=" + id; } protected static DataTable getTable(string sql) { OleDbConnection conn=new OleDbConnection(System.Configuration.ConfigurationManager.ConnectionStrings["connString"].ConnectionString); conn.Open(); using (conn) { OleDbDataAdapter oda = new OleDbDataAdapter(sql, conn); DataSet ds = new DataSet(); oda.Fill(ds); return ds.Tables[0]; } } }求各位帮忙开下怎么搞的。回11L你那个图片看不到。 //创建父节点 public void CreateTreeView() { //查询父节点 IList<Pro_type> list = Pro_typeManage.GetParentType(); foreach (Pro_type pt in list) { TreeNode nodes = CreateNode(pt.Id, ptname); CreateChildNode(pt.Id, nodes); node.ChildNodes.Add(nodes); node.Expanded = true; } } //创建TreeNode public static TreeNode CreateNode(int id, string names) { TreeNode node = new TreeNode(); node.Text = names; node.Value = Convert.ToString(id); return node; } // 创建子节点 public void CreateChildNode(int parentid, TreeNode PNode) { //父节点查询子节点 IList<Pro_type> list = Pro_typeManage.GetChildTypeByParentId(parentid); foreach (Pro_type pt in list) { TreeNode noe = CreateNode(pt.Id, ptname); //递归 PNode.ChildNodes.Add(noe); } } //创建父节点 public void CreateTreeView() { //查询父节点 IList<Pro_type> list = Pro_typeManage.GetParentType(); foreach (Pro_type pt in list) { TreeNode nodes = CreateNode(pt.Id, ptname); CreateChildNode(pt.Id, nodes); node.ChildNodes.Add(nodes);//求教磊哥,看不懂这里的node是哪转过来的 node.Expanded = true; } } 一个简单的问题 如何显示单击GridView中某一行的行号 asp.net中 2个控件的边重合 重合的边颜色会加深 我现在不要这边颜色加深 要怎么解决 关于一个分配任务列表的问题?? 问一个关于树的简单问题 有没有高手能指导一下如何注册vs2005 for crystalreport的合并模块啊 我的WEB控件在运行时为什么全部没有显示啊?并且运行时,还出一个警告框? 关于treeview控件的问题?急。。 小弟新做了个网站,请大家测试一下搜索的速度如何,谢谢了!UP有分哦 数据库没连上 管理员存储图片至服务器,如何同时存储图片的跳转地址? 如何知道嵌入网页的播放器 播放状态? 如 停止
http://topic.csdn.net/u/20100719/10/6ad767ee-b192-4e86-ac31-737c192020f5.html
找了个http://apps.hi.baidu.com/share/detail/2240056 仿照他这个来写。
但是到这一步tn.PopulateOnDemand = (Convert.ToInt32(dr["childnodecount"]) > 0 ? true : false);
我这一字段的确大于0,但是始终为false,很郁闷,不知道怎么回事。
这是我前台的页面:<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="class.aspx.cs" Inherits="xx.Admin.news._class" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="../Style/all.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div style="text-align: center;">
<asp:TreeView ID="tk" runat="server" ShowLines="true"
ShowExpandCollapse="true" OnTreeNodePopulate="tk_TreeNodePopulate">
</asp:TreeView>
</div>
</form>
</body>
</html>这个是后台的 public partial class _class : System.Web.UI.Page
{ protected int i=0;
protected string s; protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindRoot();
}
}
protected void BindRoot()
{ DataTable root = getTable(s_sql(0)); BindNode(root, tk.Nodes);
} protected void BindSub(int parent_id, TreeNode parent_node)
{
DataTable sub = getTable(s_sql(parent_id));
BindNode(sub, parent_node.ChildNodes);
}
protected void tk_TreeNodePopulate(object sender, TreeNodeEventArgs e)
{
BindSub(Convert.ToInt32(e.Node.Value), e.Node);
}
private void BindNode(DataTable dt, TreeNodeCollection nodes)
{
foreach (DataRow dr in dt.Rows)
{
TreeNode tn = new TreeNode();
tn.Text = dr["Name"].ToString();
tn.Value = dr["NK_ID"].ToString(); nodes.Add(tn);
tn.PopulateOnDemand =( Convert.ToInt32(dr["PID"]) > 0 ? true : false);
tn.SelectAction = TreeNodeSelectAction.Expand;
}
} protected static string s_sql(int id)
{
string s=string.Empty;
return s= "select * from TBNewsKind where PID=" + id;
}
protected static DataTable getTable(string sql)
{
OleDbConnection conn=new OleDbConnection(System.Configuration.ConfigurationManager.ConnectionStrings["connString"].ConnectionString);
conn.Open();
using (conn)
{
OleDbDataAdapter oda = new OleDbDataAdapter(sql, conn);
DataSet ds = new DataSet();
oda.Fill(ds);
return ds.Tables[0];
}
}
}求各位帮忙开下怎么搞的。回11L你那个图片看不到。
public void CreateTreeView()
{
//查询父节点
IList<Pro_type> list = Pro_typeManage.GetParentType();
foreach (Pro_type pt in list)
{
TreeNode nodes = CreateNode(pt.Id, ptname); CreateChildNode(pt.Id, nodes);
node.ChildNodes.Add(nodes);
node.Expanded = true;
}
}
//创建TreeNode
public static TreeNode CreateNode(int id, string names)
{
TreeNode node = new TreeNode();
node.Text = names;
node.Value = Convert.ToString(id);
return node;
}
// 创建子节点
public void CreateChildNode(int parentid, TreeNode PNode)
{
//父节点查询子节点
IList<Pro_type> list = Pro_typeManage.GetChildTypeByParentId(parentid);
foreach (Pro_type pt in list)
{
TreeNode noe = CreateNode(pt.Id, ptname); //递归
PNode.ChildNodes.Add(noe); }
}
//创建父节点
public void CreateTreeView()
{
//查询父节点
IList<Pro_type> list = Pro_typeManage.GetParentType();
foreach (Pro_type pt in list)
{
TreeNode nodes = CreateNode(pt.Id, ptname); CreateChildNode(pt.Id, nodes);
node.ChildNodes.Add(nodes);//求教磊哥,看不懂这里的node是哪转过来的
node.Expanded = true;
}
}