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

  • Thread starter Thread starter raki
  • Start date Start date
R

raki

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 //// }
 
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); ////IAMGETTING
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);
 
Back
Top