473,396 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Microsoft TreeView DataBind Performance Problems

I am seeing significant performance problems with the TreeView (from
the Microsoft.Web.UI.WebControls namespace) when trying to data bind it
on the server side. I set the TreeNodeSrc property and the
TreeNodeTypeSrc property and then call the DataBind() method. I am
setting each of these properties to a string of XML.

As the payload grows, this becomes terribly slow. This is all server
side.

I've found that this may have to do with the way the control interprets
the values of the TreeNodeSrc & TreeNodeTypeSrc properties. According
to the documentation, these properties can be set to one of three
values: "A value that indicates the URL of an XML file, System.String,
or XML data island containing TreeNode elements.". It would appear that
they way the DataBind method interrupts these values is by first
attempting to data bind to the results of a web request to a URL equal
to the value of the property. It would then appear to try and interpret
it is a string of XML. This doesn't make much sense, because, the
string of XML can be very long and it has to send out a very long web
request to try and data bind to. If you look at your web log, you'll
see requests like:

21:44:15 127.0.0.1 GET /< 404

This call obviously fails. It would appear to then properly treat it as
a string. I believe these requests (one for TreeNodeTypeSrc &
TreeNodeSrc) play a significant part in the slow down.
Does anyone have any idea about how to control this behavior?

Nov 19 '05 #1
4 2233
Aida..
I have used treeview in a coule of projects..
Binding with XML was quite cool and fast enough..from Database was quite
slow..!
U have to remember that it musn't have more than 1000 nodes (as stated
from the TreeView Web ref site)
Enjoy
Patrick

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #2
Just to be clear - I'm not dealing with a situation where I've got more
than 1000 nodes. This has much more to do with the way the server side
control databinds then anything else - at least that is my working
hypothesis.

I'm trying to work around this by sending the XML to the client-side
and databinding there, using the code in the HTC. This works for the
most part execpt the HTC's databind method doesn't appear to properly
account for the EXPANDABLE="Always" attribute on TreeNodeTypes when
those types are at the root.

Nov 19 '05 #3
I've done some more investigation, using Lutz Roeder's indispensible
..NET Reflector (http://www.aisto.com/roeder/dotnet/) and my fear has
been confirmed: the data binding code assumes the TreeNodeSrc and
TreeNodeTypeSrc are URIs and first trying to bind to them that way.
What's worse is that it uses a try...catch paradigm to find out they
aren't.

ReadXmlSrc is called, indirectly, by DataBind to perform the actual
data binding.

internal TreeView ReadXmlSrc(string TreeNodeSrc, string
TreeNodeXsltSrc, string strOuter)
{
bool flag1 = false;
if (TreeNodeSrc != string.Empty)
{
XmlTextReader reader1;
try
{
reader1 = this.GetXmlReaderFromUri(TreeNodeSrc,
TreeNodeXsltSrc);
flag1 = reader1.Read();
}
catch
{
reader1 = this.GetXmlReaderFromString(TreeNodeSrc,
TreeNodeXsltSrc);
if (reader1 != null)
{
flag1 = reader1.Read();
}
}
if ((reader1 != null) && flag1)
{
if (!reader1.IsStartElement(strOuter))
{
throw new
Exception(string.Format(Util.GetStringResource("Tr eeMissingOuterContainer"),
TreeNodeSrc, TreeNodeXsltSrc));
}
string text1 = reader1.ReadInnerXml();
string[] textArray1 = new string[5] { "<%@ Register
TagPrefix='_TreeViewPrefix' Assembly='",
typeof(TreeView).Assembly.ToString(), "'
Namespace='Microsoft.Web.UI.WebControls' %><%@ import
Namespace='Microsoft.Web.UI.WebControls' %><_TreeViewPrefix:TREEVIEW
runat='server'>", text1, "</_TreeViewPrefix:TREEVIEW>" } ;
text1 = string.Concat(textArray1);
Control control1 = this.Page.ParseControl(text1);
return (TreeView) control1.Controls[0];
}
}
return null;
}

Nov 19 '05 #4
I've done some more investigation, using Lutz Roeder's indispensible
..NET Reflector (http://www.aisto.com/roeder/dotnet/) and my fear has
been confirmed: the data binding code assumes the TreeNodeSrc and
TreeNodeTypeSrc are URIs and first trying to bind to them that way.
What's worse is that it uses a try...catch paradigm to find out they
aren't.

ReadXmlSrc is called, indirectly, by DataBind to perform the actual
data binding.

internal TreeView ReadXmlSrc(string TreeNodeSrc, string
TreeNodeXsltSrc, string strOuter)
{
bool flag1 = false;
if (TreeNodeSrc != string.Empty)
{
XmlTextReader reader1;
try
{
reader1 = this.GetXmlReaderFromUri(TreeNodeSrc,
TreeNodeXsltSrc);
flag1 = reader1.Read();
}
catch
{
reader1 = this.GetXmlReaderFromString(TreeNodeSrc,
TreeNodeXsltSrc);
if (reader1 != null)
{
flag1 = reader1.Read();
}
}
if ((reader1 != null) && flag1)
{
if (!reader1.IsStartElement(strOuter))
{
throw new
Exception(string.Format(Util.GetStringResource("Tr eeMissingOuterContainer"),
TreeNodeSrc, TreeNodeXsltSrc));
}
string text1 = reader1.ReadInnerXml();
string[] textArray1 = new string[5] { "<%@ Register
TagPrefix='_TreeViewPrefix' Assembly='",
typeof(TreeView).Assembly.ToString(), "'
Namespace='Microsoft.Web.UI.WebControls' %><%@ import
Namespace='Microsoft.Web.UI.WebControls' %><_TreeViewPrefix:TREEVIEW
runat='server'>", text1, "</_TreeViewPrefix:TREEVIEW>" } ;
text1 = string.Concat(textArray1);
Control control1 = this.Page.ParseControl(text1);
return (TreeView) control1.Controls[0];
}
}
return null;
}

Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Joe | last post by:
I'm loading a TreeView with ~8900 root nodes and only a couple of child nodes giving a total of 8910 nodes. It takes several seconds for the tree to display. The method that populates the tree...
0
by: Björn Bengtsson | last post by:
Hello! I have an urgent problem concerning ASP.NET, ADO.NET, SQL Server, XML and the TreeView control. I have two tables; one describing the products and one describing their relationships. A...
2
by: Ryo | last post by:
Hello ! I have an XmlDocument in memory and I want to put this document as datasource of my treeview. How to do this ? Thanks.
0
by: Ryo | last post by:
Hello ! I have this simple aspx page: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="test_treeview.aspx.cs" Inherits="test_treeview" Title="Treeview" %> <asp:Content...
1
by: jesper_lofgren | last post by:
Hello, Iam using Treeview control in asp.net 2.0. But have a problem. I use NavigateUrl BUT then viewstate is lost when clicked on a link i the menu. And the selected node is lost. Then i...
1
by: aaronh64 | last post by:
I'm trying to bind to the ASP.NET TreeView control and utilize the PopulateOnDemand functionality. However, I am receiving the following (very confusing) error: "PopulateOnDemand only supported...
0
by: wernh | last post by:
Hi, I have the following xml sample file: <?xml version="1.0" encoding="utf-8"?> <catalogue id="catalogue"> <alldocs id="alldocs"> <documents id="New Heading1" desc="" link="#" uid="1">...
2
by: =?Utf-8?B?QmlsbHkgWmhhbmc=?= | last post by:
Now we have to load the whole company's organizational relationships into one TreeView which has at lest 6~7 layer and including 300~400 nodes.In every node,there is a checkbox. So we need...
2
by: =?Utf-8?B?QnJpYW4gTmljaG9sc29u?= | last post by:
Hello -- I'm having problems figuring out how to bind an XML file to a treeview control. I have the following test XML: <?xml version="1.0" encoding="utf-8"?> <instruments> <instrument...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.