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

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 //// }
 
G

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 ////   }

The error means that parentTreeNode is null.

if (parentTreeNode != null)
parentTreeNode.ChildNodes.Remove(e.Node);
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top