Serverside problem when binding treeview to Xml data source

2 posts, 0 answers
  1. Earl
    Earl avatar
    1 posts
    Member since:
    Dec 2010

    Posted 01 Nov 2012 Link to this post

    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>
  2. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 05 Nov 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top