views:

423

answers:

1

Hello,

I'm working on asp.net

I've written a custom Treenode (customTreeNode) that I use to populate a treeview

the problem comes up when firing the selectnodechanged event

this event give me a TreeNode object and not a customTreeNode

and I cannot seem to cast it somehow,

does sy have a clue ?

Thx

here is the code I have

populate my tree

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

customTreeNode

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 the event

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





        }

treeViewSiteCollection.SelectedNode is of type TreeNode and I cannot cast it.

Thx guys

A: 

You must extend the tree itself also check this post http://forums.asp.net/p/1109208/1713613.aspx#1713613

Osama Ibrahim