Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I group my child nodes to it's corresponding parent node?
    primarykey
    data
    text
    <p>I am new to C#/ASP.Net. and I have a project now that involves binding a tree from two SQL Table. I've done some home work.. and I was able to bind my tree. first here are my tables. My goal is to group my child to it's corresponding parent. but what happens is it the child goes into all the parents. I know i am almost there but i got stuck. :(</p> <pre><code>tblCategory(parentnodes) categoryID(varchar(20)) Category(varchar(50)) active(char(1)) tblDocuments(childnodes) id(int) description(varchar(100)) title(varchar(20)) categoryid(varchar(20)) tblcategory.categoryid = tbldocuments.categoryid </code></pre> <p>here are my codes.</p> <pre><code> protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { //bindtree DataTable dtCategoryNodes = new DataTable(); dtCategoryNodes = content.dtCategoryNodes(); dtCategoryNodes.AcceptChanges(); DataTable dtNodes = new DataTable(); dtNodes = content.GetNodes(); dtNodes.AcceptChanges(); TreeNode CategoryNode = null; for (int i = 0; i &lt; dtCategoryNodes.Rows.Count; i++) { string categoryid = dtCategoryNodes.Rows[i]["CategoryID"].ToString(); CategoryNode = new TreeNode(dtCategoryNodes.Rows[i] "CATEGORY"].ToString()); CategoryNode.Collapse(); for (int j = 0; j &lt; dtNodes.Rows.Count; j++) { string parentid = dtNodes.Rows[j]["parentid"].ToString(); TreeNode childNode = new TreeNode(dtNodes.Rows[j]["TITLE"].ToString()); CategoryNode.ChildNodes.Add(childNode); } tvContents.Nodes.Add(CategoryNode); tvContents.DataBind(); } } } </code></pre> <p>but i had a problem here. here is what happened to my tree.</p> <pre><code>a. Crift Items a.1Configuring DCOM b.Internal Refresher Trainings b.1Configuring DCOM c. Product/Process Update c.1 Configuring DCOM d.Promotions/Discounts d.1 Configuring DCOM e.QA Update e.1 Configuring DCOM </code></pre> <p>below is my data tbldocument id Title File CategoryID 1 Configuring DCOM DCOM.doc PRODUPDT</p> <pre><code>tblCategory CategoryID Category active CRIFT Crift Items Y IRTRAIN Internal Refresher Trainings Y PRODUPDT Product/Process Update Y PROMODISCS Promotions/Discounts Y QAUPDT QA Update Y </code></pre> <p>Appreciate all comments and suggestions! Thanks in advance!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload