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
280
WebHierarchicalDataSource with self-referencing data
posted

I am having a problem getting my self-referencing datasource set up.  I think it has something to do with the actual data that is coming back and what the WHDS is expecting.  Here's my situation: we have a middle tier solution setup that returns type Collection<Organization>.  Organization is a business object that contains 3 important fields for our application: OrganizationID, ParentOrgID, and OrganizationName.  I am trying to bind this to a WebDataTree in an Hierarchial fashion, but here's the tricky part.  A node is a root Node when its ParentOrgID is 0 OR its a root Node when its ParentOrgID is not present in the list.  This is because some of our business methods return filtered lists which may not contain Organizations with an OrganizationID of 0.  They return a small branch of the whole complete tree or several branches.

Additionally, there are a few thousand entries returned at times (obviously I want to use some sort of paging in the end).

I know the ObjectDataSource is working correct as I am able to bind it to a drop down list and if I take the DataRelation out of the WHDS, the tree binds, but not the way I want.  My only conclusion is that there is some expected format for the data in order for the DataRelation to work properly.  Thoughts?

    <ig:WebHierarchicalDataSource ID="dataSource" runat="server" RootDataViewID="View1">
        <DataRelations>
            <ig:DataRelation ChildColumns="ParentOrgID" ChildDataViewID="View1" ParentColumns="OrganizationID"
                ParentDataViewID="View1" />
        </DataRelations>
        <DataViews>
            <ig:DataView ID="View1" DataSourceID="allOrgsDS" />
        </DataViews>
    </ig:WebHierarchicalDataSource>
    <asp:ObjectDataSource ID="allOrgsDS" runat="server" TypeName="MiddleTier"
        SelectMethod="getOrganizations"></asp:ObjectDataSource>