Binding Treeview to Sitemap - Adding dynamic items

R

Ray Booysen

Hi all

I have a treeview bound to a sitemap. Once the user is logged in, I'm
wanting the menu to expand to include additional items from a database
while retaining the items in the sitemap. Is this possible.

For example.

My menu has an item called "Books" defined in the sitemap. Once the
user logs in, I want sub menu-items to be created under books with all
the books the user owns. This would be pulled from the database.

Any ideas?

Kind Regards
Ray
 
G

Guest

The treeview can do this very easily. First, make sure you add some string
to a treenode's Value property that will allow you to determine what node you
are dealing with and what data you need to get out of the database to create
its child nodes. Next, set ExpandDepth to 0, make sure EnableClientScript is
true, and PopulateNodesFromClient is true. Lastly, add an event handler in
your webpage for the TreeNodePopulate event. When that event fires, check in
the event args for a treenode. Get the Value from it and retrieve the
specified data from the database. lastly, create child nodes from this data
and add them to this node's .Children property.

All this happens without a postback to the web server; the user just sees a
slight delay and then the nodes come.
 
R

Ray Booysen

Not sure why this is happening but the TreeNodePopulate event never
fires. The DataBinding and DataBound events fire but not the populate
event.

Also, as I'm binding to a sitemap, I can't set the value of the treenode
as I don't have access to this property.

Any ideas?

Regards
Ray
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top