CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 4/21/2006 10:41:00 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 4 Views: 24 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
5 Items, 1 Pages 1 |< << Go >> >|
therubble
Asp.Net User
TreeView and Removing Nodes4/21/2006 10:41:00 AM

0/0

I got a web.sitemap bound to a treeview control, inside the sitemap I've setup an attribute called "removefromsitemap".

On the nodedatabound event, i grab the sitemapnode and see what the value of the above attribute is, and then depending on that I decide whether to remove the node.

I use the following line, ctrTreeView.Nodes.Remove(e.node), if placed inside the If statement, it executes the line and the node isn't removed, place it outside the statemenet and the whole treeview disappears as expected.

Why is this happening, I just want to be able to remove nodes based on the sitemap attribute.

Thanks

Chriss


Where there's a will, I wanna be in it.
dannychen
Asp.Net User
Re: TreeView and Removing Nodes4/24/2006 2:24:51 PM

0/0

Chris,

  I'm not exactly sure what your code is so I can't be specific, however, if you have any kind of hierarchy to your sitemap (more than 1 level of nodes), the line of code you are showing won't work.

Nodes.Remove only removes nodes from the specific collection, in this case, that would be the root nodes collection.  If your node was lower in the tree, that line wouldn't do anything because the node didn't exist in the collection.

The correct thing to do would be:

If e.Node.ParentNode IsNot Nothing Then
  e.Node.ParentNode.ChildNodes.Remove(e.Node)
Else
  ctrTreeView.Nodes.Remove(e.Node)
End If

Other than that, I don't know why your whole tree disappears if you move the code around, I'd have to see more of your code to tell you.
--
Danny


disclaimer: Information provided is 'as is' and conveys no warranties or guarantees.
therubble
Asp.Net User
Re: TreeView and Removing Nodes4/24/2006 2:59:34 PM

0/0

Excellent that solved the issue, thought I was gonna have to rewrite the sitemap provider for a little while there.
Where there's a will, I wanna be in it.
James25
Asp.Net User
Re: TreeView and Removing Nodes11/21/2007 8:56:27 PM

0/0

Hi! Can you please explain how you did it. I am kinda new to the treeview control.

Cheers!

therubble
Asp.Net User
Re: TreeView and Removing Nodes11/22/2007 8:16:34 AM

0/0

If e.Node.ParentNode IsNot Nothing Then
  e.Node.ParentNode.ChildNodes.Remove(e.Node)
Else
  ctrTreeView.Nodes.Remove(e.Node)
End If

Put the above code in the nodebound, or nodebinding event a long time since I did it, If you tell me exactly what you are trying to do it may jog my memory. 

 


Where there's a will, I wanna be in it.
5 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Sams Teach Yourself Visual Basic 2005 in 24 Hours: Complete Starter Kit Authors: James D. Foxall, Pages: 536, Published: 2006
Sams Teach Yourself Visual Basic.Net in 24 Hours Authors: James D. Foxall, Pages: 508, Published: 2001
Application Development Using Visual Basic and .NET Authors: Robert J. Oberg, Peter Thorsteinson, Dana L. Wyatt, Pages: 830, Published: 2002
Pro .NET 2.0 Windows Forms and Custom Controls in C#: From Professional to Expert Authors: Matthew MacDonald, Pages: 1037, Published: 2005
Pro .NET 2.0 Windows Forms and Custom Controls in VB 2005 Authors: Matthew MacDonald, Pages: 1036, Published: 2006
Programming Python: Object-Oriented Scripting Authors: Mark Lutz, Pages: 1255, Published: 2001
ASP.NET AJAX Programmer's Reference: With ASP.NET 2.0 Or ASP.NET 3.5 Authors: Shahram Khosravi, Pages: 1522, Published: 2007
C# for Programmers: Updated for C# 2.0 Authors: Paul J. Deitel, Pages: 1317, Published: 2005
Visual Basic 2005: How to Program Authors: Harvey M. Deitel, Pages: 1513, Published: 2006
Mastering Visual Basic.NET Authors: Evangelos Petroutsos, Pages: 1153, Published: 2002

Web:
How to: Add and Remove Nodes with the Windows Forms TreeView Control The Windows Forms T:System.Windows.Forms.TreeView control stores the top-level nodes in its P:System.Windows.Forms.TreeView.Nodes collection. Each T:System.
Removing Nodes - TreeView Control - developerFusion - the global ... Remove 12. Note that if a node has sub items when it is removed, all its sub items are removed too. If you want to remove all the nodes in the TreeView, ...
treeview.nodes.remove does nothing - ASP.NET Forums treeview.nodes.remove does nothing. Last post 10-20-2006 3:20 PM by mctnguy. 4 replies. Sort Posts:. Oldest to newest, Newest to oldest ...
Weird TreeView.Nodes.Remove/Find problem - GameDev.Net Discussion ... NET ยป Weird TreeView.Nodes.Remove/Find problem. search: ... I appear to be having a strange problem with my Win Forms Treeview(.NET 2.0). ...
Treeview - Remove node - Fanatic Live I want to remove the node from a treeview. But to remove a node you need to know the index number of that node. ...
Remove a Node in Treeview Remove a Node in Treeview. Hi All, I have a treeView control, the treeview is generated from DB. I need to write a function to remove some ...
TreeView and Removing Nodes - ASP.NET Forums TreeView and Removing Nodes. Last post 08-20-2008 1:34 PM by muymoy. 6 replies. Sort Posts:. Oldest to newest, Newest to oldest ...
Add, remove, disable nodes โ€“ r.a.d.treeview Add, remove, disable nodes โ€“ radtreeview. ... You can delete nodes by using the Remove method of the Nodes collection. Disabling/Enabling nodes can be ...
Deleting a Node in the Tree View Deleting a Node in the Tree View. Along the left side of the window that contains your DOM tree, there are buttons that represent the types of nodes you can ...
How to: Add and Remove Nodes with the Windows Forms TreeView Control Because the Windows Forms TreeView control displays nodes in a hierarchical manner, when adding a node you must pay attention to what its parent node is.




Search This Site:










dropdownlist question

i'm just beginning

need advice

how to insert textbox values into a new url string for database filter use.

linq to sql templates

announcing gotcodesnippets.net

custom servercontrol

how do i get the runtime installed on a server for deployment?

need help with a general exception error

copy web site stoped working

installation - compilation error - bc30451: name 'config' is not declared

remote administrator of ou.

asp.net backward compatibility

converting vs.net proj 2003 to 2002 error

server application unavailable

long html email?

to authenticate domain for application use. any one please

where does hashtable gets created

control rendering of treeview's nodes when databound to sitemapprovider?

mobile application

install into db with community server already there

sorting and paginating a gridview

how to clear the querystring of the url

detect browser close before session timeout asp.net

formatdatetime returns different result on servers

problem with usercontrols and masterpages

cms rerieve pages from sql table

how do i get at todays date in asp.net 2

how could i link a child portal ?

questions

 
All Times Are GMT