Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Populating the TreeView control from the SQL server in C# .NET application [modified]

Populating the TreeView control from the SQL server in C# .NET application [modified]

Scheduled Pinned Locked Moved C#
csharpquestiondatabasesql-serversysadmin
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    thachil
    wrote on last edited by
    #1

    How can I populate the treeview from the SQL server by using the ID and Parent ID of the node? :confused: -- modified at 4:07 Saturday 23rd June, 2007

    Joseph Thachil +91 9916025724

    C 1 Reply Last reply
    0
    • T thachil

      How can I populate the treeview from the SQL server by using the ID and Parent ID of the node? :confused: -- modified at 4:07 Saturday 23rd June, 2007

      Joseph Thachil +91 9916025724

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      I suspect you'd have to iterate over the data, I don't think a tree view is a data bound control. If it doesn't have a data source property, you need to do it 'by hand'.

      Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      T 1 Reply Last reply
      0
      • C Christian Graus

        I suspect you'd have to iterate over the data, I don't think a tree view is a data bound control. If it doesn't have a data source property, you need to do it 'by hand'.

        Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        T Offline
        T Offline
        thachil
        wrote on last edited by
        #3

        I can add parent node and child node, but i can't add child of child node.

        +91 9916025724 Joseph Thachil

        S 1 Reply Last reply
        0
        • T thachil

          I can add parent node and child node, but i can't add child of child node.

          +91 9916025724 Joseph Thachil

          S Offline
          S Offline
          sidbaruah
          wrote on last edited by
          #4

          Its possible to add child of child nodes. TreeView TreeView1=new TreeView(); foreach (TreeNode tn in TreeView1) { TreeNode tn1; if (TreeView1.Nodes[intTreeCount].Value == treeNodeValue) { tn.Nodes.Add(tn1); } int childcount=tn1.ChildNodes.Count; if(childcount>0) { tn1.childNodes.Add(tn2); } and so on....

          I was born dumb!! :laugh:Programming made me laugh:laugh:!!! --sid--

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups