Click here to Skip to main content
15,892,480 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
Hi..
I have a treeview which contain one parent and other childnodes.I want when i click on child node then selected child node value access on other page and page redirect.Here is my screenshot treeview image
When i click on parent(UIIT) then its working fine i retrieve value in other page and page redirect,but i want the child value UIIT child values e.g UIIT,ARID,info etc.When i click ARID then this value retrieve in other page.how can i do this.

What I have tried:

C#
 Master.FindControl("TreeView1");
 Master.FindControl("TreeView8");
 TreeView tv = (TreeView)Master.FindControl("TreeView1");
 TreeView tv8 = (TreeView)Master.FindControl("TreeView8");
 SqlDataAdapter da = new SqlDataAdapter(cmd);
 da.Fill(dt);
 cnn.Close();
 var parentNode = new TreeNode("Database");
 var parentNode2 = new TreeNode("UIIT");
 TreeNode node = new TreeNode();
 if (dt.Rows.Count > 0)
 {
  int total = dt.Rows.Count;
  if (total >= 3)
 {
  for (int i = 0; i < dt.Rows.Count; i++)
 {
    DataRow row = dt.Rows[i];
    string value = row["Database_Name"] + "";
    parentNode.ChildNodes.Add(new TreeNode(value));
    parentNode2.ChildNodes.Add(new TreeNode(value));
}
    var temp = new TreeNode("More") { NavigateUrl = "~/More_DB.aspx" };
    parentNode.ChildNodes.Add(temp);
    parentNode2.ChildNodes.Add(temp);
    else
   {
    foreach (DataRow row in dt.Rows)
   {
    string value = row["Database_Name"] + "";
    parentNode.ChildNodes.Add(new TreeNode(value));
    parentNode2.ChildNodes.Add(new TreeNode(value));
  }   
   var temp = new TreeNode("More") { NavigateUrl = "~/More_DB.aspx" };
   parentNode.ChildNodes.Add(temp);
   parentNode2.ChildNodes.Add(temp);
  }
   tv.Nodes.Add(parentNode);
   tv8.Nodes.Add(parentNode2);
   for (int i = 0; i < tv8.Nodes.Count; i++)
   {
   if (tv8.Nodes[i].Selected==true)
   {
     Session["NAM"] = tv8.Nodes[i].Text;
     Page.Response.Redirect("showTable.aspx");
   }
   }
   }
   }

This code is working but for parent,when i select UIIT then values retrieve on other page using session,but i want when i click on UIIT childs then these values retrieve on other page.Thanks in advance
Posted
Updated 29-Apr-16 21:33pm
v2
Comments
Member 12003400 30-Apr-16 3:39am    
Pass childnode value as querystring with Navigation URL
Hameed Khan 30-Apr-16 3:43am    
How can i paas,actaully last loop contain logic about this.can you help me
Hameed Khan 30-Apr-16 3:44am    
I try this parentnode2.childnodes.count in loop and in if statement parentnode2.childnode[i] but its not working

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900