473,405 Members | 2,373 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Learnig to Build a Tree View Control

Does anyone know of a good article that discusses creating a "Tree
View" control in ASP.NET? Or perhaps a Tree View Control that comes
with source code? I have come across a lot of tree controls for ASP.NET
however most of them are already compiled and don't come with source
code. I am really just looking for an example on how to create my own
Tree Control. Thanks a bunch.

Nov 19 '05 #1
10 2491
Creating a Tree View Control is the same as creating or designing an
application. You enumerate a set of requirements, look at the available
tools and technologies, figure out what will satisfy your requirements, and
come up with a plan. Rather than looking at examples of how other people
soved the problem, why not look at this as an opportunity to practice your
analysis and design skills?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"dwok" <de***@wubbafish.net> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Does anyone know of a good article that discusses creating a "Tree
View" control in ASP.NET? Or perhaps a Tree View Control that comes
with source code? I have come across a lot of tree controls for ASP.NET
however most of them are already compiled and don't come with source
code. I am really just looking for an example on how to create my own
Tree Control. Thanks a bunch.

Nov 19 '05 #2
It is extremely simple.
While I do not have the time to go into greater detail regarding how it
is the topics you should be familiar with already are
Using the Viewstate to store your own variables.
Creating custom classes that are serializable and deserialiazable
and Recursiveness

if i were you i would build a custom class that implements ICollection.
This will be referred to as your NodeCollection from here on out.
You will have another custom class. This will be referred to as your
Node from here on out.
Both have to be marked as Serializable. Look up this Attribute in the
msdn library.
For speed skae you should implement ISerializable and implement the
special constructor and add and retrieve all of your variables
manually. This requires more code but offers a significate performance
boost as it doesnot have to use reflection when serializaing and
deserializing.

Your TreeNode will have a property that is of the type NodeCollection.
you will override LoadViewState and SaveViewState and by simply adding
your Tree's Node Collection to the viewstate everything is serialized
automatically and deserialized. All you have to do is add and retrieve
it from the Viewstate.

Rendering is simply a matter of Recursive ness.
foreach (treenode in treenodecollection)
{
render node
callself(treenode.Nodes)
}

Hope this is helpful in any way

Nov 19 '05 #3
spoken like a true MVP

Nov 19 '05 #4
Did you intend for this to be helpful?

Nov 19 '05 #5
if you goto the book store and look at the javascript/html section, you
should find lots of material on this and other html ui components. in the
asp.net seciton you may even find .net implimentations.

if you go to any website that has a tree control you like, with the browser
view source to see the code. firefox has really good tools for this.

-- bruce (sqlwork.com)

"dwok" <de***@wubbafish.net> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
| Did you intend for this to be helpful?
|
Nov 19 '05 #6
Hello Dwok,
Check out the control gallery at ww.asp.net:
It has an entire section dedicated to treeviews:
http://www.asp.net/ControlGallery/de...=28&tabindex=2

I personally have used this one with success (it's free):
http://www.asp.net/ControlGallery/Co...014&tabindex=2

Some tips to get you started:
1 - Think out your requirements. Do the nodes need to be multi-line? Should
they be able to contain any HTML (images, tables, etc...) or just single
literal strings or links.
2 - How will you set the data? With an xml file, from a DataTable (with
recursive columns), programatically?
3 - Figure out your javascript/html needs: (1) how to children collapsed
(hidden), (2) how to persist across postback. Look at the view-source for
other successful treeviews.
"dwok" wrote:
Does anyone know of a good article that discusses creating a "Tree
View" control in ASP.NET? Or perhaps a Tree View Control that comes
with source code? I have come across a lot of tree controls for ASP.NET
however most of them are already compiled and don't come with source
code. I am really just looking for an example on how to create my own
Tree Control. Thanks a bunch.

Nov 19 '05 #7
Hi,

For building the treeview control u should decide on which data source u
r going to use to populate the tree view. i have developed a treeview control
in which the nodes and all the info. required for the elements in the tree
view control are in XML files. then using XML dom we can parse through that
and develop the tree view control.
for more info. regarding the tree view control u can look into the
june2004 edition of MSDN Magazine.

Regards,
Sundararajan.S

"Tim Stall" wrote:
Hello Dwok,
Check out the control gallery at ww.asp.net:
It has an entire section dedicated to treeviews:
http://www.asp.net/ControlGallery/de...=28&tabindex=2

I personally have used this one with success (it's free):
http://www.asp.net/ControlGallery/Co...014&tabindex=2

Some tips to get you started:
1 - Think out your requirements. Do the nodes need to be multi-line? Should
they be able to contain any HTML (images, tables, etc...) or just single
literal strings or links.
2 - How will you set the data? With an xml file, from a DataTable (with
recursive columns), programatically?
3 - Figure out your javascript/html needs: (1) how to children collapsed
(hidden), (2) how to persist across postback. Look at the view-source for
other successful treeviews.
"dwok" wrote:
Does anyone know of a good article that discusses creating a "Tree
View" control in ASP.NET? Or perhaps a Tree View Control that comes
with source code? I have come across a lot of tree controls for ASP.NET
however most of them are already compiled and don't come with source
code. I am really just looking for an example on how to create my own
Tree Control. Thanks a bunch.

Nov 19 '05 #8
How do you think I came to become one? ;-)

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"re****@community.nospam" <ma**********@gmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
spoken like a true MVP

Nov 19 '05 #9
If you're replying to me, the answer would be "yes, doubtless more helpful
than you realize."

Which is more helpful - to feed a man a fish, or to teach a man to fish?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"dwok" <de***@wubbafish.net> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Did you intend for this to be helpful?

Nov 19 '05 #10
Thank you for all the replies. A lot of people suggested on how to
start planning for a TreeView control but what I am really looking for
is an example. As I see it there are many things to consider when
developing an ASP.NET TreeView control.

1. client-side vs. server-side interaction
2. datasource (XML, Dataset, Collection, etc..)
3. Node properties
4. Load entire tree vs. single node

These are all things that I think would be made much clearer to me if
I had an example to look at. There are many great treeview controls out
there for ASP.NET however I would like to be able to look at the source
code in order to understand how they are created.

Nov 19 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Tree menu using XML | last post by:
I have one XML file that has nodes and sub node and each and every node has the attribute call visible if its value is true then diplay this node else don't display thid node, but this condition i...
1
by: Nick Warrington | last post by:
Hi all, I am having a small problem with a tree control I am playing with. I have created a custom tree view that displays nodes with a linktext control to the right of the nodes. When the...
1
by: Kaye | last post by:
It seems that when I dynamically resize items in a tree-view control, using TVM_SETITEM and the TVITEMEX iIntegral member, things go awry. The window draws properly, but it seems like the RECTs for...
3
by: Alan Silver | last post by:
Hello, I am just looking at the tree view control, which looks very good, but has some apparent limitations. This could easily be my lack of experience with it. Specifically, I have two...
1
by: JN | last post by:
Hi All, I have a tree view which has parent nodes of each letter of the alphabet. The root node will be the customers name that relate to the parent node letter. I also have a gridview which is...
0
by: Santosh | last post by:
Asp.Net tree view control font problem Dear all i am downloading MS tree view control . i want to change the font size and font name of the tree view control i am wrtitting code for it like ...
0
by: rinishrk | last post by:
Hi, I have a web application that contains subfolders Admin and User with related webpages inside them. Within the Admin folder I have a page containing a Tree View Control.I want this tree view...
1
by: perspolis | last post by:
Hi all I'm looking for a Combobox that displays tree. Does anyone has a source code for that??? thanks in advance
1
by: BeginingOfLife | last post by:
i am using a java script to create a tree view in my html page. i got that script from this link : http://destroydrop.com/javascripts/tree/ given script is static script creations for tree...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.