(I already made a post today asking how to use parameterized queries for the datasources used by WebHierarchicalDataSource. But now we have a more disturbing issue).
We want to load a fair amount of data in our WebDataTree, and the database tables are very large, so we wanted to use the "Load On Demand" feature of the WebDataTree. We also want to use the convenient and (in theory at least) very cool WebHierarchicalDataSource.
So ... I noticed that the datasources bound to levels 1 and 2 our tree hierarchy were being populated in first-time logic (IsPostBack = false), even though InitialDataBindDepth="0" was set for the WebDataTree. I thought it was something we were doing, but I created a test web project using the AdventureWorks database that was almost identical to the "Load On Demand" sample, except it used the AdventureWorks on SQL Server. I turned on the SQL Server profiler and confirmed that the database was being hit right away. When you click on a level 0 node, the database is hit AGAIN.
So what's the story? Does anyone know? Am I doing something wrong? To me this seems like an out-an-out bug, and makes a joke of the term "Load On Demand".
BillyB
I should probably be a bit clearer: the rendered HTML that is sent to the client does NOT include all the bound child nodes in the hierarchy. In the UI sense, it is in fact "load on demand." However, the WebHierarchical datasource IS binding the entire hierarchy behind the scenes in first-time logic even with the InitialDataBindDept set to 0, and consequently causing a huge hit to the database.
Just because the web servers aren't stressed doesn't mean the database won't be brought to it's knees, which will have the same effect.
Hello BIlly,
Thank you for posting in our forums.
The clarification was very helpful because I was not able to reproduce the issue with the online sample
http://samples.infragistics.com/aspnet/Samples/WebDataTree/Performance/LoadOnDemand/Default.aspx?cn=data-tree&sid=e3bab63c-d017-4547-8a27-785d948b90a6
You are correct LoadOnDemand of the tree refers to the population of the nodes , but not to the hierarchical datasource.
If you want to bind only the first level of the WebDataTree and load from the database the others on demand, you should use manual load on demand.
http://samples.infragistics.com/aspnet/Samples/WebDataTree/Performance/ManualLoadOnDemand/Default.aspx?cn=data-tree&sid=c257cd9c-1c5a-4159-aa51-ff8ea8386395
Let me know if you need further assistance.
What can't you reproduce? Are you saying that the entire Products table wasn't read from the database? I'm sorry, but I proved that to myself with the SQL Server 2008 Profiler. Are you saying the profiler shows differently for you?
My point was that just because all the Products aren't rendered and sent to the client doesn't mean this is "load on demand". A bad dbms query can bring a website to its knees just as much - if not more so - than a lot of rendering. Reading an entire dbms table not once but TWICE might be acceptable in a toy application with 20 or 30 rows, but I'd be fired if I put something like that in production with hundreds of thousands of rows. No joke; I would be.
Anyway, actually what I ended up doing was much like that manual load-on-demand, Tsvetelina. I manually added the nodes myself. But when you do that, I understand from old Forum posts that not all DataTreeNode events fire.
I also understood from some forum posts that you can't use Templates when you use DataTreeNodeCollection.Add(). So what I had to do was format complex HTML myself in code-behind and set the DataTreeNode.Text property. It worked, but it was a tedious and time-consuming process since I couldn't see in the Visual Studio Designer what the layout looked like.
So I have my workaround, but I'm left wondering what this WebHierarchicalDataSource is good for.
You did ask if you be of further assistance ... so is there a way to use templates when I add nodes manually? That would be very helpful.
Thanks!
-B
Hello Billy,
Thank you for the update and the detailed explanation.
I do not state that the entire product table wasn't read. I am saying that not all the nodes were loaded on the client. And this is the "load on demand" functonality of the WebDataTree when is not manual mode.
Regarding the templates you can add template using the TemplateId property.
Please refer to the below
http://community.infragistics.com/forums/p/58875/299267.aspx
Recently another customer was trying to implement similar requirement with WebExplorerBar
http://community.infragistics.com/forums/t/60316.aspx