Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > abt tree view in asp.net can i hide the tree nodes ?

Reply
Thread Tools

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

 
 
raki
Guest
Posts: n/a
 
      06-24-2009
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 //// }
 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      06-24-2009
On Jun 24, 1:25*pm, raki <nhrak...@gmail.com> 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);
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating Tree view nodes in code Sumz ASP .Net 1 10-25-2008 03:43 PM
Hi, I want to implement a General Tree Data structure (Not Binary Tree ) which have more than 2 sub nodes? sharan C Programming 4 10-30-2007 08:21 PM
problem in saving tree view nodes in a xml file fa_2064@yahoo.com ASP .Net 0 09-20-2006 01:09 PM
Newbie: Trouble accessing all nodes in a tree view clsmith66 ASP .Net Web Controls 2 10-28-2004 03:55 PM
How to Collapse all the nodes of a tree view? Luis E Valencia ASP .Net 0 06-01-2004 09:46 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57