简体   繁体   中英

Asp.net TreeView control - maximum number of nodes

I have a treeView control in ASP.NET page that will be loaded with up to 12,000 nodes in different levels. For example:

  • Node 1

    • Node 1.1 …

      • Node 1.400

        • Node 1.400.1

        • Node 1.400.6400
  • Node 2
  • Node 3
  • Node 4

According to this link:

http://msdn.microsoft.com/en-us/library/ms529261.aspx

the node limit is 1000. Is this correct or is it dependent on available memory(please specify value)?

Assuming it is correct. is there any way to split the 4600 child nodes in say in chunks of 300 hundred? I am thinking that if dummy nodes are used (previous /next navigation) to navigate the chunks will easy the load of the html page.

Sample code in C# will be greatly appreciated. (Or VB.NET if you can not translate it to C#)

TreeNode node;
node = new TreeNode(Session["Type"].ToString(), Session["Type"].ToString(), "", "Sub_cat.aspx?MainCat=" + Session["Type"].ToString(), "");
node.SelectAction = TreeNodeSelectAction.SelectExpand;
TreeView1.Nodes.Add(node);
string str1 = "select * from sub_cat where main_cat='"+Session["Type"].ToString() +"'"; ///+ node.Text + "'";
dt1 = db.gettable(str1);
for(int x=0;x<dt1.Rows.Count;x++)
{
    //Session["subcat"] = dt1.Rows[x]["sub_cat"].ToString();
    string sub = dt1.Rows[x]["sub_cat"].ToString();
    TreeNode node1 = new TreeNode(dt1.Rows[x]["sub_cat"].ToString(), dt1.Rows[x]["sub_cat"].ToString(), "", "Product_collection.aspx?sub_cat=" + sub, "");
    node1.SelectAction = TreeNodeSelectAction.SelectExpand;
    //TreeView1.Nodes.Add(node1);
    node.ChildNodes.Add(node1);

    string str2 = "select * from product_master where main_cat='" + Session["Type"].ToString() + "' and sub_cat='" + node1.Text + "' order by product_code asc";
    dt2 = db.gettable(str2);
    for(int y=0;y<dt2.Rows.Count;y++)
    {
       // Session["product_code"]=dt2.Rows[y]["product_code"].ToString();
        string code = dt2.Rows[y]["product_code"].ToString();
        TreeNode node2 = new TreeNode(dt2.Rows[y]["product_code"].ToString(), dt2.Rows[y]["product_code"].ToString(), "", "prod_desc.aspx?product_code=" + code, "");
        node2.SelectAction= TreeNodeSelectAction.SelectExpand;
        node1.ChildNodes.Add(node2);
    }
}

最后,我们使用Obout 树视图,因为它没有我的问题中提到的asp.net树视图的限制,而且我可以毫无问题地加载1000个节点,并且其虚拟加载功能很棒。

是的,这是真的,我在阅读了此链接后实际上已经对其进行了检查: http://social.msdn.microsoft.com/Forums/zh-CN/csharpgeneral/thread/dcacb090-73a2-4845-ab19-e280ea373ffb

You should not load more than the visible nodes at once, when user expands a node level you can/could/should/must use load on demand to load the children and so on recursively only when needed.

Do not overload the page rendering loading all nodes, makes no sense.

search for load on demand asp.net treeview and similar...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM