Custom TreeNode and SelectNodeChanged

I am working on asp.net and I wrote my own TreeNode (customTreeNode) which I use to populate the TreeView.

The problem occurs when the selectnodechanged event is fired, which gives me a TreeNode object, not a customTreeNode. I also cannot tell him apart.

This is how I populate my tree:

 node.ChildNodes.Add
                (
                    customTreeNode = new customTreeNode(site)
                );

      

My customTreeNode class:

public class customTreeNode : TreeNode
    {
       public Guid Id { get; set; }
        private SPWebEntry _dataContext;
        public SPWebEntry DataContext
        {
            get
            {
                return _dataContext;
            }
        }

        public customTreeNode(SPWebEntry DataContext)
        {
            _dataContext = DataContext;

            this.Text = _dataContext.Title;
            this.Id = _dataContext.Id;
        }
}

      

and event

 void treeViewSiteCollection_SelectedNodeChanged(object sender, EventArgs e)
        {
            treeViewSiteCollection.SelectedNode;
        }

      

treeViewSiteCollection.SelectedNode

is of type TreeNode and I cannot tell the difference.

0


a source to share


1 answer


You should also expand the tree check this post http://forums.asp.net/p/1109208/1713613.aspx#1713613



0


a source







All Articles