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

Regarding Treeview

0 Answers 14 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Swapnil
Top achievements
Rank 1
Swapnil asked on 06 Dec 2013, 05:43 AM
Hi
i am having treeview which shows parent node as company name and child node as employee name
there may be 2 conditions possible
1 ] IF logged in user is COMPANY ADMIN then the parent node=Company name and Child Nodes are employees from that company 

and image is also given
2 ] IF logged in user is SUPER USER then he can view all company as parent names and the employees in that company name
image is given and also code
private void BindToDataTable(RadTreeView RadTreeView1)
   {
       RadTreeView1.DataSource = "";
       RadTreeView1.DataBind();
        
       int UserId = Convert.ToInt32(Session["UserId"].ToString());
       int RoleId = Convert.ToInt32(Session["RoleId"].ToString());
       Temp = objGlobas.BindTreeView_Test(UserId, RoleId);
 
       //Get Permission to logged in user individually and by group and combine these Entities into one datatable dt2
 
       Globas ObjGlobas = new Globas();
       DataTable dtViewPermission = new DataTable();
       dtViewPermission = ObjGlobas.ViewPermission(UserId);
 
       DataTable RootNode = new DataTable();
       RootNode = Temp;
       DataView dView = new DataView(RootNode);
       string[] arrColumns = { "CompName", "CompId" };
       RootNode = dView.ToTable(true, arrColumns);
       if (Convert.ToInt32(Session["RoleId"]) == 1)
       {
           DataTable dtchildnode = new DataTable();
            
           if (Temp.Rows.Count > 0 && Temp != null)
           {
               foreach (DataRow row in RootNode.Rows)
               {
                   RadTreeNode tnparent = null;
                   string ParentNode = row["CompName"].ToString().Trim();
                   string ParentID = row["CompId"].ToString().Trim();
                   tnparent = new RadTreeNode(ParentNode);
                   tnparent.Value = ParentID.ToString();
                   RadTreeView1.Nodes.Add(tnparent);
                   tnparent.AllowEdit = false;
                   tnparent.ContextMenuID = "contextMenu1";
 
                   int CompanyId = Convert.ToInt32(ParentID);
                   dtchildnode = ObjGlobas.BindTreeView_SuperUser(CompanyId);
                   foreach (DataRow dr in dtchildnode.Rows)
                   {
                       RadTreeNode Child = null;
                       string child = dr["EntityName"].ToString();
                       string EntityId = dr["EntityId"].ToString();
                       Child = new RadTreeNode(child);
                       Child.Value = EntityId;
                       tnparent.Nodes.Add(Child);
                       Child.ContextMenuID = "contextMenu2";
                   }
               }
           }
       }
       else
       {
           if (Temp.Rows.Count > 0 && Temp != null)
           {
               foreach (DataRow row in RootNode.Rows)
               {
                   RadTreeNode tnparent = null;
                   string ParentNode = row["CompName"].ToString().Trim();
                   string ParentID = row["CompId"].ToString().Trim();
                   tnparent = new RadTreeNode(ParentNode);
                   tnparent.Value = ParentID.ToString();
 
                   RadTreeView1.Nodes.Add(tnparent);
                   tnparent.AllowEdit = false;
                   tnparent.ContextMenuID = "contextMenu1";
 
 
                   foreach (DataRow dr in dtViewPermission.Rows)
                   {
                       RadTreeNode Child = null;
 
                       string child = dr["EntityName"].ToString();
                       string EntityId = dr["EntityId"].ToString();
                       Child = new RadTreeNode(child);
                       Child.Value = EntityId;
                       tnparent.Nodes.Add(Child);
                       Child.ContextMenuID = "contextMenu2";
                   }
               }
           }
       }
      
        
   }


my problem is while SUPER USER login for each companys child node stored procedure is executing,is there any alternative way to do this.
Thanks

No answers yet. Maybe you can help?

Tags
TreeView
Asked by
Swapnil
Top achievements
Rank 1
Share this question
or