abt tree view in asp.net can i hide the tree nodes ?

Discussion in 'ASP .Net' started by raki, Jun 24, 2009.

  1. raki

    raki Guest

    hi all,

    Iam suffering with a problem can we hide the nodes in treeview
    depend upon the user login i just tried some code but it was not
    woking properly plz can u any one help mee as early as possible
    thanks.

    code:
    protected void Page_Load(object sender, EventArgs e)
    {
    TreeView1.TreeNodeDataBound += new TreeNodeEventHandler
    (TreeView1_TreeNodeDataBound);
    SiteMapDataSource1.Provider = this.SiteMapDataSource1.Provider;
    }
    protected void TreeView1_TreeNodeDataBound(object sender,
    TreeNodeEventArgs e)
    {
    SiteMapNode thisMapNode = (SiteMapNode)e.Node.DataItem;
    TreeNode parentTreeNode = e.Node.Parent;
    if (thisMapNode["isPhantom"] != null && thisMapNode
    ["isPhantom"].ToLower().Equals(bool.TrueString.ToLower()) &&
    parentTreeNode != null)
    parentTreeNode.ChildNodes.Remove(e.Node); ////IAM GETTING
    ERROR HERE AS OBJECT INSTRANCE IS NOT SET TO ANOTHER INSATANTCE OF AN
    OBJECT //// }
     
    raki, Jun 24, 2009
    #1
    1. Advertising

  2. On Jun 24, 1:25 pm, raki <> wrote:
    > hi all,
    >
    >        Iam suffering with a problem can we hide the nodes in treeview
    > depend upon the user login i just tried some code but it was not
    > woking properly plz can u any one help mee as early as possible
    > thanks.
    >
    > code:
    > protected void Page_Load(object sender, EventArgs e)
    >     {
    >         TreeView1.TreeNodeDataBound += new TreeNodeEventHandler
    > (TreeView1_TreeNodeDataBound);
    >        SiteMapDataSource1.Provider = this.SiteMapDataSource1.Provider;
    >             }
    >      protected void TreeView1_TreeNodeDataBound(object sender,
    > TreeNodeEventArgs e)
    >     {
    >         SiteMapNode thisMapNode = (SiteMapNode)e.Node.DataItem;
    >         TreeNode parentTreeNode =  e.Node.Parent;
    >         if (thisMapNode["isPhantom"] != null && thisMapNode
    > ["isPhantom"].ToLower().Equals(bool.TrueString.ToLower()) &&
    > parentTreeNode != null)
    >             parentTreeNode.ChildNodes.Remove(e.Node); ////IAM GETTING
    > ERROR HERE AS OBJECT INSTRANCE IS NOT SET TO ANOTHER INSATANTCE OF AN
    > OBJECT ////   }


    The error means that parentTreeNode is null.

    if (parentTreeNode != null)
    parentTreeNode.ChildNodes.Remove(e.Node);
     
    Alexey Smirnov, Jun 24, 2009
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Luis E Valencia

    How to Collapse all the nodes of a tree view?

    Luis E Valencia, Jun 1, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    916
    Luis E Valencia
    Jun 1, 2004
  2. Replies:
    0
    Views:
    350
  3. Sumz
    Replies:
    1
    Views:
    291
  4. Parthiv Joshi
    Replies:
    1
    Views:
    801
    Samuel L Matzen
    Jul 6, 2004
  5. clsmith66

    Newbie: Trouble accessing all nodes in a tree view

    clsmith66, Oct 27, 2004, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    124
    clsmith66
    Oct 28, 2004
Loading...

Share This Page