search
Twitter Rss Feeds
MicrosoftArticlesForumsGroups
C# .NET
VB.NET
Visual Studio .NET
ADO.NET
Xml/Xslt
VB 6.0
.NET CF
GDI+
LINQ
Deployment
Security
FoxPro
Silverlight / WPF
Entity Framework
RIA Services

Web ProgrammingArticlesForumsGroups
JavaScript
ASP
ASP.NET
Web Services

Non-MicrosoftArticlesForumsGroups
NHibernate
Perl
PHP
Ruby
Java
Linux / Unix
Apple
Open Source

DatabasesArticlesForumsGroups
SQL Server
Access
Oracle
MySQL
Other Databases

OfficeArticlesForumsGroups
Microsoft Excel
Microsoft Word
Microsoft Powerpoint
Publisher
Money

Operating SystemsArticlesForumsGroups
Windows 7
Windows Server
Windows Vista
Windows XP
Windows Update
MAC
Linux / UNIX

Server PlatformsArticlesForumsGroups
Share Point
BizTalk
Site Server
Exhange Server
IIS
Transaction Server

Graphic DesignArticlesForumsGroups
Macromedia Flash
Adobe PhotoShop
Microsoft Expression

OtherArticlesForumsGroups
Subversion / CVS
Ask Dr. Dotnetsky
Active Directory
Networking
Uninstall Virus
Job Openings
Reviews
Search Engines
Resumes

 

Previous Thread:   strange question about DropDownList

1/15/2006 4:19:13 AM    Inheriting from the TreeNode class
Hello  
  
I have a written a class that inherits from the TreeNode class  
  
I want to use the inherited TreeNode class to attach custom properties to  
  
the nodes in a TreeView web control  
  
I am trying to use the TreeNodePopulate event to read the custom property  
  
when the user expands a node  
  
The problem is that the custom node is not recognised when the event fires  
  
after the page has been rendered  
  
How can I access the custom node during postbacks, I get the feeling that  
  
the custom node isn't being created, even though I've overridden the  
  
CreateNode method, is there something else I should do? Do I need to  
  
override other methods that persist the custom properties of the custom  
  
treenode? Am I doing this the wrong way? Should I take an entirely different  
  
approach?  
  
Here is some of the code  
  
public class CustomTreeView : TreeView  
  
{  
  
protected override TreeNode CreateNode()  
  
{  
  
return new CustomTreeNode();  
  
}  
  
}  
  
public class CustomTreeNode : TreeNode  
  
{  
  
private int customInt;  
  
public int CustomInt  
  
{  
  
get  
  
{  
  
return customInt;  
  
}  
  
set  
  
{  
  
customInt= value;  
  
}  
  
}  
  
}  
  
protected void customTreeView_TreeNodePopulate(object sender,  
  
TreeNodeEventArgs e)  
  
{  
  
CustomTreeNode node = e.Node as CustomTreeNode;  
  
// node == null  
  
// i need to access node.CustomInt  
  
...  
  
}  
  
Thanks  
  
Alex


Pete's Blog   |    Pete's Resume   |    Robbe's Blog   |    Robbe's Resume   |    Archive #2   |    Archive #3   |    Dotnetslackers   |    XmlPitStop   |    Advertise   |   Contact Us   |   Privacy   |   Copyright (c) 2000 - 2009 eggheadcafe.com  All rights reserved.