I am binding Telerik RadTreeView
from a Datatable
. I want to expand the radTreeView
nodes at root level (node.level=0)
and their child only (node.level=1)
from serverside.
Datatable contains a column which holds the value for node's level. But the radTreeView
doesn't expand at all.
This is the code:
IList<RadTreeNode> allNodesBS = tvAssets.GetAllNodes();
for (int i = 0; i < allNodesBS.Count; i++)
{
RadTreeNode node = (RadTreeNode)allNodesBS[i];
string nodeLevel = dt.Rows[i]["bs_node_level"].ToString();
if (nodeLevel == "0" || nodeLevel == "1")
{
node.Expanded = true; //doesn't work
}
}
//tvAssets.ExpandAllNodes(); This works
tvAssets.ExpandAllNodes();
works but I don't want to expand all the nodes because it contains large number of nodes.
And I can't do it from clientside because it has some issues.
Please try with the below code snippet. To bind data I have used programmatic data binding method but below code works for all binding.
ASPX
ASPX.CS
Let me know if any concern.