title: Asp.net Treeview with check boxes
body: <p>Below is my treeview control in aspx page</p>
  
  <pre><code> &lt;asp:TreeView ID="TvCategories" runat="server" ShowCheckBoxes="All"    OnSelectedNodeChanged="TvCategories_SelectedNodeChanged"&gt;
  &lt;/asp:TreeView&gt;
  </code></pre>
  
  <p>I am binding it dynamically as below:</p>
  
  <pre><code>    DataSet ds = new DataSet();
      DataTable dt = new DataTable();
      ds = BindCategories();
      dt = ds.Tables[0];
  
     for (int i = 0; i &lt; dt.Rows.Count; i++)
     {
        TreeNode firstchild = new TreeNode();
        firstchild.Text = " Shoes";
        firstchild.SelectAction = TreeNodeSelectAction.Select;
        TvCategories.Nodes.Add(firstchild);
        DataSet ds1 = new DataSet();
        ds1 = BindSubCategories(dt.Rows[i]["InventoryType"].ToString());
        DataTable dt1 = ds1.Tables[0];
  
        for (int j = 0; j &lt; dt1.Rows.Count; j++)
        {
             TreeNode childnode = new TreeNode();
             childnode.SelectAction = TreeNodeSelectAction.Select;
  
             if (j == 0)
                childnode.Text = "Nike";
             if (j == 1)
                childnode.Text = "Rebok";
             if (j == 2)
                childnode.Text = "Addidas";
                firstchild.ChildNodes.Add(childnode);
  
         }
    } 
  </code></pre>
  
  <p>Below is the image of treeview when I run the Web application in browser:<br/>
  <img src="https://i.stack.imgur.com/3BtO2.png" alt="enter image description here"></p>
  
  <p>What I want to do?</p>
  
  <p>By selecting the root node will also select all the child node and visa versa <br/>
  when I select any child or any root, an postback event will fire  and based on selecting I want to bind gridview.</p>