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

maintain the state or radtreeview

1 Answer 78 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
subrahmanyam kameswara
Top achievements
Rank 1
subrahmanyam kameswara asked on 13 May 2010, 10:33 AM
HI,

I have a radtreeview in asp.net

I am dynamically building the radtreenodes and adding to the Radtreeview.

and I am dynamically adding the radgrid control to some of the node of the radtreeview.

plz find the below code
 protected void createtreenodes()
        {
            RadTreeNode tNode1 = null;
            RadTreeNodeCollection tnc = null;
                rdTrNewBusiness.Nodes.Clear();
                DataSet dsNode = new DataSet();
                dsNode.ReadXml(Server.MapPath("~/XMLs/NewPolicyLinks.xml"));
                dt = new DataTable();
                dt = dsNode.Tables[0];

              
                for (int j = 0; j < dt.Rows.Count; j++)
                {
                    tNode1 = new RadTreeNode();
                    tNode1.Text = dt.Rows[j]["Name"].ToString();
                    rdTrNewBusiness.Nodes.Add(tNode1);

                    tNode1.ExpandMode = TreeNodeExpandMode.ServerSide;

                    if (tNode1.Text == "POLICY")
                    {
                        BindPolicy(tNode1);
                    }
                    else if (tNode1.Text == "ENTITIES")
                    {
                        NodeTxt = BindGrids(tNode1, tNode1.Text, "~/XMLs/EntitiesInfo.xml");
                        tNode1.Text = "ENTITIES" + " (" + NodeTxt + ")";

                        if (!object.Equals(Session["Node"], null))
                        {
                            if (Session["Node"].ToString().Trim().Length > 0)
                            {
                                tNode1.Expanded = true;
                            }
                        }
                    }
                    else if (tNode1.Text == "COVERAGE")
                    {
                        BindCoverage(tNode1);
                    }
                    else if (tNode1.Text == "VEHICLES")
                    {
                        NodeTxt = BindGrids(tNode1, tNode1.Text, "~/XMLs/Vehicle.xml");
                        tNode1.Text = "VEHICLES" + " (" + NodeTxt + ")";

                    }
                    else if (tNode1.Text == "DRIVERS")
                    {
                        NodeTxt = BindGrids(tNode1, tNode1.Text, "~/XMLs/DriversInfo.xml");
                        tNode1.Text = "DRIVERS" + " (" + NodeTxt + ")";

                    }
                    else if (tNode1.Text == "HISTORY")
                    {
                        NodeTxt = BindGrids(tNode1, tNode1.Text, "~/XMLs/CarrierInfo.xml");
                        tNode1.Text = "HISTORY" + " (" + NodeTxt + ")";
                    }

                    else if (tNode1.Text == "RATE")
                    {
                        BindRate(tNode1);
                    }
                }
               tnc  = new RadTreeNodeCollection(rdTrNewBusiness);
                tnc.Add(tNode1);
                Cache["Tree"] = tnc;
                dsNode = null;
            }


The problem is when we are clicking on any grid row (which is dynamically constructed radgrid), all the tree nodes are in collapse mode, i want the node which is expanded with the grid to maintain the same state.

could any one plz help me how to maintain the state of the radtreeview which is dynamically created in postbacks.

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 13 May 2010, 12:52 PM
Hi,

I hope the following code library will give some insight on saving the expanded state of RadTreeView control.
Save the expanded state of the TreeNodes when the treeview is being bound upon each postback

Regards,
Princy.
Tags
TreeView
Asked by
subrahmanyam kameswara
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or