This is a migrated thread and some comments may be shown as answers.

Serverside problem when binding treeview to Xml data source

1 Answer 48 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Earl
Top achievements
Rank 1
Earl asked on 01 Nov 2012, 02:22 PM
I have created a treeview that binds to an xml data source (I followed the instructions on the following page: http://demos.telerik.com/aspnet-ajax/treeview/examples/programming/xmlfile/defaultcs.aspx). If the 'ExpandMode' property in the data bindings is not set then the data is displayed by the treeview as expected - however, the server postback doesn't work correctly when you click on a node. If you set the ExpandMode property to 'ServerSide' the treeview does not populate correctly.

What am I doing wrong?

        <telerik:RadTreeView ID="XmlRadTreeView" runat="server"
            DataSourceID="TreeViewDataSource"
            DataFieldID="Text"
            DataFieldParentID="Text"
            PersistLoadOnDemandNodes="true"
            Width="550px"
            Height="350px"
            BorderStyle="Solid"
            BorderWidth="1px"
            Font-Size="14px"
            Font-Names="Bookman Old Style"
            BackColor="White"
            EnableViewState="true"
            OnNodeCollapse="XmlRadTreeView_NodeCollapse"
            OnNodeExpand="XmlRadTreeView_NodeExpand"
            OnNodeClick="XmlRadTreeView_NodeClick">
            <DataBindings>
                <telerik:RadTreeNodeBinding DataMember="Node" PostBack="true" ValueField="ID" TextField="Text" ImageUrlField="ImageUrl" ExpandedField="Expanded" ExpandMode="ServerSide"></telerik:RadTreeNodeBinding>
            </DataBindings>
            <NodeTemplate>
                <div class="CustomClass">
                    <%# DataBinder.Eval(Container, "Text") %>
                </div>
            </NodeTemplate>
        </telerik:RadTreeView>

1 Answer, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 05 Nov 2012, 03:56 PM
Hello Earl,

I did some some modifications to your project in order to work fine with data populated from XML data source.
Please keep in mind that DataFieldID and DataFieldParentID are unnecessary in case of using DataBings for DataMember="Node".

Please find the sample project based on the provided demo attached to this response.

Hope that this will lead you into right direction.

Regards,
Boyan Dimitrov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
TreeView
Asked by
Earl
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Share this question
or