treeview, checked

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Limno
    New Member
    • Apr 2008
    • 92

    treeview, checked

    I have used the treeview control in my C# web application. In that i have a few parent nodes and there child nodes. i have set the ShowCheckboxes properties as ALL.
    So if the ckeck box of a parent node or child node is checked how can i get the value of that checked nodes?
    In the foreach loop what code should i use?
    Please help me.
  • shweta123
    Recognized Expert Contributor
    • Nov 2006
    • 692

    #2
    Hi,

    You can use checked property of Treeview node to check that if that node is checked or not?
    e.g.
    Code:
     foreach (TreeNode nd in TreeView1.Nodes) { 
            foreach (TreeNode cnd in nd.ChildNodes) { 
             //Check for all child nodes if it is checked
                if ((cnd.Checked)) { 
                  .................
                } 
            } 
            if ((nd.Checked)) { 
               //check for parent node if it is checked
                .................            
            } 
        }
    Originally posted by Limno
    I have used the treeview control in my C# web application. In that i have a few parent nodes and there child nodes. i have set the ShowCheckboxes properties as ALL.
    So if the ckeck box of a parent node or child node is checked how can i get the value of that checked nodes?
    In the foreach loop what code should i use?
    Please help me.

    Comment

    • Limno
      New Member
      • Apr 2008
      • 92

      #3
      Thanks 4 replying me,

      can u suggest me, another query,
      i wnt to display d database values in 3 levels through treeview.

      ie.
      Parent Node
      ChildNode
      SubChildNode

      Please help me the c#.net Code, SQL 2005, Urgent!!!!!!!!

      Thanks in Advance.






      Originally posted by shweta123
      Hi,

      You can use checked property of Treeview node to check that if that node is checked or not?
      e.g.
      Code:
       foreach (TreeNode nd in TreeView1.Nodes) { 
              foreach (TreeNode cnd in nd.ChildNodes) { 
               //Check for all child nodes if it is checked
                  if ((cnd.Checked)) { 
                    .................
                  } 
              } 
              if ((nd.Checked)) { 
                 //check for parent node if it is checked
                  .................            
              } 
          }

      Comment

      • shweta123
        Recognized Expert Contributor
        • Nov 2006
        • 692

        #4
        Hi,

        1) You can write the stored procedure for getting the Parent node and all the child nodes related to that parent node and for storing that data in some table using SQL SERVER 2005.

        2) Call above stored procedure from .Net code. Select the data stored in the table and display it in the Treeview.

        Comment

        • Limno
          New Member
          • Apr 2008
          • 92

          #5
          Thanks 4 replying me,

          Another query plz.

          I have a treeview control with showcheckboxes = All in my C#.net web application.

          When i check on the child node its parent node should be checked automatically.s imilarlly when i uncheck a parent node all its childnodes should be unckecked.

          When i check on the parent node all its child nodes should be checked automatically.


          How can i do this?

          is any possible way to do this........

          Comment

          • shweta123
            Recognized Expert Contributor
            • Nov 2006
            • 692

            #6
            Hi,

            You can refer this Link

            Comment

            Working...