Learnig to Build a Tree View Control

Discussion in 'ASP .Net Building Controls' started by dwok, Mar 8, 2005.

  1. dwok

    dwok Guest

    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.
     
    dwok, Mar 8, 2005
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:...
    > 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.
    >
     
    Kevin Spencer, Mar 8, 2005
    #2
    1. Advertising

  3. dwok

    Guest

    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
     
    , Mar 8, 2005
    #3
  4. dwok

    Guest

    spoken like a true MVP
     
    , Mar 8, 2005
    #4
  5. dwok

    dwok Guest

    Did you intend for this to be helpful?
     
    dwok, Mar 8, 2005
    #5
  6. dwok

    bruce barker Guest

    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" <> wrote in message
    news:...
    | Did you intend for this to be helpful?
    |
     
    bruce barker, Mar 8, 2005
    #6
  7. dwok

    Tim Stall Guest

    Hello Dwok,
    Check out the control gallery at ww.asp.net:
    It has an entire section dedicated to treeviews:
    http://www.asp.net/ControlGallery/default.aspx?Category=28&tabindex=2

    I personally have used this one with success (it's free):
    http://www.asp.net/ControlGallery/ControlDetail.aspx?Control=1014&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.
    >
    >
     
    Tim Stall, Mar 8, 2005
    #7
  8. dwok

    Sundararajan Guest

    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/default.aspx?Category=28&tabindex=2
    >
    > I personally have used this one with success (it's free):
    > http://www.asp.net/ControlGallery/ControlDetail.aspx?Control=1014&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.
    > >
    > >
     
    Sundararajan, Mar 9, 2005
    #8
  9. How do you think I came to become one? ;-)

    --
    HTH,

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

    "" <> wrote in message
    news:...
    > spoken like a true MVP
    >
     
    Kevin Spencer, Mar 9, 2005
    #9
  10. 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" <> wrote in message
    news:...
    > Did you intend for this to be helpful?
    >
     
    Kevin Spencer, Mar 9, 2005
    #10
  11. dwok

    dwok Guest

    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.
     
    dwok, Mar 9, 2005
    #11
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dwok
    Replies:
    10
    Views:
    709
  2. Stub

    B tree, B+ tree and B* tree

    Stub, Nov 12, 2003, in forum: C Programming
    Replies:
    3
    Views:
    10,145
  3. raki
    Replies:
    1
    Views:
    1,154
    Alexey Smirnov
    Jun 24, 2009
  4. Parthiv Joshi
    Replies:
    1
    Views:
    729
    Samuel L Matzen
    Jul 6, 2004
  5. dwok

    Learnig to Build a Tree View Control

    dwok, Mar 8, 2005, in forum: ASP .Net Web Controls
    Replies:
    10
    Views:
    212
Loading...

Share This Page