Hi, I can not keep the state of the tree in the Master page.
This is my code
I looked at other similar threads in the forum, but couldn't do it
This is my code
public List<
string
> BindNodes
{
get
{
List<
string
> dataNodes = new List<
string
>();
dataNodes.Add("item1");
dataNodes.Add("item2");
dataNodes.Add("item3");
return dataNodes;
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
BindTree();
}
private void BindTree()
{
List<
string
> data= BindNodes;
for (int i = 0; i <
data.Count
; i++)
LoadRecursive(data[i], null);
}
private void LoadRecursive(string item, RadTreeNode parentNode)
{
if (parentNode == null)
{
RadTreeNode
childNode
=
new
RadTreeNode();
childNode.Value
=
"5"
;
childNode.Text
=
item
;
childNode.Category
=
"category1"
;
childNode.ExpandMode
=
TreeNodeExpandMode
.ClientSide;
tree.Nodes.Add(childNode);
parentNode
=
childNode
;
}
List<string> secondList= new List<
string
>();
secondList.Add("sec1");
secondList.Add("sec2");
for (int i = 0; i < secondList.Count; i++)
{
RadTreeNode childNode = new RadTreeNode();
childNode.Value = "5";
childNode.Text = secondList[i];
childNode.Category = "category2";
childNode.ExpandMode = TreeNodeExpandMode.ClientSide;
parentNode.Nodes.Add(childNode);
//LoadRecursive(subSite[i], childNode);
}
}
protected void tree_NodeClick(object sender, RadTreeNodeEventArgs e)
{
switch (tree.SelectedNode.Category.ToString())
{
case "category1":
Response.Redirect("~/Member/Cat1.aspx?id=" + tree.SelectedValue);
break;
case "category2":
Response.Redirect("~/Member/Cat2.aspx?id=" + tree.SelectedValue);
break;
}
}