Learn how to a build a cloud-first strategyRegister Now


Web Treeview

Posted on 2012-09-13
Medium Priority
Last Modified: 2012-10-27

I'm building a web page that has treeview control.  The data for the treeview is derived from a database.  Is it possible to have the treeview node display one piece of text but also store an additional value which can be accessed by the program?
I thought of doing this by a tag property but this doesn't seem to be available in web tree view control.
Question by:andyw27
  • 2
  • 2
LVL 20

Accepted Solution

Daniel Van Der Werken earned 2000 total points
ID: 38396331
Would the TagName property work for this?

One thing I've done is create an "associated" HashTable that hold values. Then, for each TreeView node text value  you add, add the additional value to the HashTable:

HashTable additionalValues = new HashTable();
...for each new TreeView Node:
    treeview1.Nodes.Add(  myNode );
   additionalValues[ myNode.Text ] = additionalValueForNode;
... and so forth.

then, when the user clicks on the node, you grab the selected node text and do a lookup by seeing the value:

object myValue = additionalValues[ selectedNode.Text ];


Author Comment

ID: 38396384
Thanks, I like the idea of the hash table however how do you handle instances where you have two nodes with identical text?
LVL 20

Expert Comment

by:Daniel Van Der Werken
ID: 38400072
Since the HashTable can handle any object, use a struct:
public struct MyMostExcellentStruct
   public string MyMostExcellentString;
   public int MyMostExcellentInt;

for each new Node....
    MyMostExcellentStruct mmes = new MyMostExcellentStruct();
    mmes.MyMostExcellentString = "Some Extremely Excellent String Value";
    mmes.MyMostExcellentInt = 12345;

    additionalValues[ myNode.Text ] = mmes;


Open in new window


Author Comment

ID: 38451071
thanks, out of interest how do I get the value back out of the struct?

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month21 days, 2 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question