Search code examples
c#telerikradtreeview

How do I refresh my RadTreeView


I have a RadTreeView that isn't getting updated when the datasource changes.

This is the code in my ascx.

<div class="demo-container size-thin" style="display: inline-block">
    <telerik:RadTreeView RenderMode="Lightweight" ID="AssessmentCriteriaTree" runat="server"  Width="200px" Height="620px"
        OnClientNodeClicked="OnClientNodeClicked" OnNodeDataBound="AssessmentCriteriaTree_NodeDataBound">
        <DataBindings>
            <telerik:RadTreeNodeBinding Expanded="True"></telerik:RadTreeNodeBinding>
        </DataBindings>
    </telerik:RadTreeView>
</div>

In the code behind the data binding happens with this code.

DataTable dtTree = ds.Tables[0];
AssessmentCriteriaTree.DataTextField = "Val";
AssessmentCriteriaTree.DataFieldID = "ID";
AssessmentCriteriaTree.DataFieldParentID = "ParentID";
AssessmentCriteriaTree.DataSource = dtTree;
AssessmentCriteriaTree.DataBind();

When the page loads initially, the tree is built correctly but when the same code is hit that changes the datasource, the tree doesn't change. When debugging the OnNodeDataBound event I can see that the new data is being processed so it looks like that part is working correctly. It just doesn't update in the UI.


Solution

  • In another section on the page was where the button was to trigger the update to the datasource. It was in a RadAjaxPanel. My treeView was not inside the RadAjaxPanel. I moved it inside and it is now getting refreshed.