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
315
Can't rebind a tree to the data source to refresh the nodes
posted

Hi,

I have an ultrawebtree which is being populated from a hierarchical data source. The code works fine when the page is loaded and the tree is displayed correctly.

My problem is that certain events require me to refresh the data source, and of course the tree. I simply can't find a way to do this. My data source is programmatically defined in the back end, by calling a function which returns the relevant data. Anything I try and do I either get an error or the tree stays the same. Rebinding the datasource definitely updates the data selection, but does nothing to the tree. If I try and to a tree.databind, it tells me my datasourceid is blank.

I'd rather point my tree directly to a dataset programmatically anyway without using this on page data source but I haven't found any code that seems to be able to do that.

Code:

hierarchical data source:

    <ig:WebHierarchicalDataSource ID="whDataSource" runat="server">
        <DataRelations>
            <ig:DataRelation ChildColumns="ParentGroupID"
                ChildDataViewID="Sub" ParentColumns="GroupID"
                ParentDataViewID="Root" />
            <ig:DataRelation ChildColumns="ParentGroupID"
                ChildDataViewID="Sub" ParentColumns="GroupID"
                ParentDataViewID="Sub" />
        </DataRelations>
    </ig:WebHierarchicalDataSource>

so I've set up the name and the relations.

on the tree, i've set the datasourceid = "whDataSource", and then the bindings as:

                                            <DataBindings>
                                                <ignav:NodeBinding DataMember="Root" TextField="GroupName" TagField="GroupID" />
                                                <ignav:NodeBinding DataMember="Sub" TextField="GroupName" TagField="GroupID" />
                                            </DataBindings>

in the back end code I simply populate the data source:

        Dim dsGroups As DataSet
        Dim obData As New dmCardsData.clUsers

        dsGroups = obData.GetUserGroups(MyParameter1, MyParameter2) 'returns a data set with 2 views in it for the root and the sub records
        obData = Nothing
        dsGroups.DataSetName = "Group"

        whDataSource.DataSource = dsGroups
        Dim prView1 As New Infragistics.Web.UI.DataSourceControls.DataView
        prView1.DataSource = dsGroups.Tables(0).DefaultView
        Dim prView2 As New Infragistics.Web.UI.DataSourceControls.DataView
        prView2.DataSource = dsGroups.Tables(1).DefaultView
        whDataSource.DataViews.Add(prView1)
        whDataSource.DataViews.Add(prView2)
        whDataSource.DataViews(0).ID = "Root"
        whDataSource.DataViews(1).ID = "Sub"
        whDataSource.DataBind()
        dsGroups = Nothing

 

So this works fine when I first load the page. All I want to do is have the ability to refresh the data. Rerunning the above does refresh the data, but doesn't do anything to the tree. If I try putting the line dtGroups.databind() after reloading the data, it tells me "DataView has no DataSourceID or DataSource set."

If I try programmatically resetting all of the dtGroups data bindings (which were already set in the page code anyway), ie;

        dtGroups.DataBindings.Clear()
        dtGroups.DataSourceID = "whDataSource"
        Dim prBinding1 As New Infragistics.WebUI.UltraWebNavigator.NodeBinding
        prBinding1.DataMember = "Root"
        prBinding1.TextField = "GroupName"
        prBinding1.TagField = "GroupID"
        dtGroups.DataBindings.Add(prBinding1)
        Dim prBinding2 As New Infragistics.WebUI.UltraWebNavigator.NodeBinding
        prBinding2.DataMember = "Sub"
        prBinding2.TextField = "GroupName"
        prBinding2.TagField = "GroupID"
        dtGroups.DataBindings.Add(prBinding2)

it STILL tells me the same error, "DataView has no DataSourceID or DataSource set."

Any help appreciated, it doesn't seem like I'm trying to do anything that complicated, just reload a tree from a data source!

Parents
No Data
Reply Children
No Data