Gary King

Gary King

  • NA
  • 83
  • 159.1k

TreeNode - How can I add a control (LinkButton)?

Jan 27 2011 11:38 AM

I am creating a TreeView dynamically in code behind and currently it only contains text (taken from database).
What I want to do is display the text (as I am currently doing) and add a LinkButton at the end. If the user clicks on the text of the node (eg "Red" in the example below), then the browser is re-directed to another page. If the user clicks on the LinkButton text ("Delete") then a function is called that deletes the associate record in the database.
So, for example (the "Delete" is the LinkButton):
- Colours
       - Red     Delete
       - Green  Delete
       - Blue     Delete
The way that my existing code (without Delete) works is that I have a DataReader that gets the values (Red, Green, Blue) from the database and creates a child TreeNode with the .Text value being the current value. I also set .NavigateUrl to another page (so I cannot use NavigateUrl to perform the delete)
Is it possible to add a LinkButton, or are there any suggestions as to alternative approaches?

Answers (4)