We want to create a web page with a 3-level WebDataTree and bind it to a WebHierarchicalDataSource containing multiple ObjectDataSources. The 2nd and 3rd levels will return a fair amount of data, and the database tables containing the data are very large. The "Load On Demand" sample (http://samples.infragistics.com/aspnet/Samples/WebDataTree/Performance/LoadOnDemand/Default.aspx?cn=data-tree&sid=e3bab63c-d017-4547-8a27-785d948b90a6) in the IG "Features and Samples" section is pretty close to what we are trying to do, even though it uses SQLDataSources.
Here's our problem/question: the "ProductsDS" SQLDataSource for the 2nd-level nodes selects the entire Products table. That just isn't gonna work for our million+ row tables. What we want to do is use parameterized queries like this in our HTML:
<asp:ObjectDataSource ID="odsTeamNodes" runat="server" onselecting="odsTeamNodes_Selecting" SelectMethod="SelectTeamNodes" TypeName="odsLgStandings" > <SelectParameters> <asp:Parameter Name="prmSportsLeagueActorId" Type="Int32" /> <asp:Parameter Name="prmLeagueSeasonEventId" Type="Int32" /> <asp:Parameter Name="prmDivisionActorId" Type="Int32" /> </SelectParameters> </asp:ObjectDataSource>
and this in our code-behind:
protected void odsTeamNodes_Selecting(object sender, ObjectDataSourceSelectingEventArgs e) { int divisionActorId = treeLgStandings.ActiveNode == null ? -1 : Convert.ToInt32(treeLgStandings.ActiveNode.Key); e.InputParameters["prmSportsLeagueActorId"] = _LeagueOrg.ActorId; e.InputParameters["prmLeagueSeasonEventId"] = _LeagueSeasonEvent.EventId; e.InputParameters["prmDivisionActorId"] = divisionActorId; }
The problem we're having is how/where to set the parameters so they have the correct values when
the Selecting event handlers for the datasources fire. We've tried creating
event handlers for NodePopulate, NodeBound, and NodeClick and setting them there, but these
seem to fire in a strange order and at unexpected times, and/or the values are just not there.
So ... How might we extend the example to have parameterized queries for the "ProductsDS" datasource?
If we can make that work, our page would probably work as well.
Thanks in advance,
-Billy B
Hello Billy,
did you see the other sample with Manual Load On Demand http://samples.infragistics.com/aspnet/Samples/WebDataTree/Performance/ManualLoadOnDemand/Default.aspx?cn=data-tree&sid=c257cd9c-1c5a-4159-aa51-ff8ea8386395 . Isn't it more appropriate for this scenario?
Thank you, yes - I did see that example. And in fact to get the job done I've coded a completely manual version wherein I add to the nodes collection myself as that example app does for level 1 in the tree.
But Hristo, there are big costs to this manual approach. I understand from old Forum posts that when I add nodes manually (A) not all DataTreeNode events fire, and worse (B) I cannot use Templates without binding. (or can I?). I was forced to manually format HTML strings in my code-behind and then set the DataTreeNode.Text property. It wasn't fun.
So then what's point of using this WebHierarchicalDataSource if I can't use parameterized queries to limit my database load?Perhaps I should have posted there, but my question remains. What good is WebHierarchicalDataSource if I have to read an entire database table in order to use it?
The WebHierarchicalDataSource seems like a real productivity booster, but without the ability to do what I'm asking, it seems able to handle only toy applications. A real production app with hundreds of thousands or even a couple of million rows would be out of the question.
Anyway, thanks for the response!
-B