Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
600
How to use parameterized queries with WebDataTree and WebHierarchicalDataSource ?
posted

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
Parents Reply Children
No Data