Hello friends,
Please I need your help, I have this Query:
SELECT c.CategoryID , p.ProductID , c.CategoryName , p.ProductName FROM Categories as C INNER JOIN Products as PON c.CategoryID = p.CategoryID
I need to show a tree with the head of the Parent Category table and within the detail of the Product table.
Please friend, any idea?
Thanks, God Bless you.
Hello Eros,
There are different approaches to achieve the desired behavior. The first one is to split your query with Inner join to two different queries, without inner join. The first one will be select from your Categories table – Parent table, and second query (from Products) will be your child table. You could include both tables (the result set from your two queries) in DataSet. Then you could create a Relation between both tables using the same connection like it is in your Inner join.
Other approach could be by using directly the result set from your inner join (please note that by this was you will have duplicate items in your Categories table). I made small sample that shows the second approach. Please take a look at the attached sample for more details. Please let me know if you have any questions.
Regards
Have you been able to resolve your issue ? Did you have a time to take a look at the attached sample. Please let me know if you have any questions.
Thanks for all. That the force with be you.
Could you please take a look at the latest modification in my sample. Please let me know if you have any questions.
Hello, thanks for replying, I tried your example and I've added 3 more products and the UltraTree control is displayed like my results, please how I can fix this.
dt.Rows.Add(0,"cCategoryName 0","cCategoryDesc 0", 0, 0, "pProductName 0"); dt.Rows.Add(1, "cCategoryName 1", "cCategoryDesc 1", 1, 100, "pProductName 100"); dt.Rows.Add(1, "cCategoryName 1", "cCategoryDesc 1", 1, 101, "pProductName 101"); dt.Rows.Add(1, "cCategoryName 1", "cCategoryDesc 1", 1, 102, "pProductName 102"); dt.Rows.Add(2, "cCategoryName 2", "cCategoryDesc 2", 2, 103, "pProductName 103"); dt.Rows.Add(3, "cCategoryName 3", "cCategoryDesc 3", 3, 104, "pProductName 104"); dt.Rows.Add(4, "cCategoryName 4", "cCategoryDesc 4", 4, 105, "pProductName 105"); dt.Rows.Add(1, "cCategoryName 1", "cCategoryDesc 1", 1, 106, "pProductName 106"); dt.Rows.Add(2, "cCategoryName 2", "cCategoryDesc 2", 2, 107, "pProductName 107"); dt.Rows.Add(3, "cCategoryName 3", "cCategoryDesc 3", 3, 108, "pProductName 108");
Could you please take a look at the attached sample, and please feel free to modify my sample to reproduce your issue and revert it back to me. I`ll be glad to research the issue for you. Please let me know if you have any quesitons.
Please, my UltraTreeView are grouped by product and within the list of categories.
This is my Code from Initialize the UltraTree
If (e.Node.Level = 0 And OldValue <> e.Node.Cells("cCategoryID").Text) Then e.Node.Cells("cCategoryID").Column.Visible = True e.Node.Cells("cCategoryName").Column.Visible = True e.Node.Cells("cDescription").Column.Visible = True e.Node.Cells("pProductID").Column.Visible = False e.Node.Cells("pCategoryId").Column.Visible = False e.Node.Cells("pProductName").Column.Visible = False e.Node.Visible = True ElseIf (e.Node.Level = 1) Then e.Node.Cells("cCategoryID").Column.Visible = False e.Node.Cells("cCategoryName").Column.Visible = False e.Node.Cells("cDescription").Column.Visible = False e.Node.Cells("pProductID").Column.Visible = True e.Node.Cells("pCategoryId").Column.Visible = True e.Node.Cells("pProductName").Column.Visible = True Else e.Node.Visible = False End If OldValue = e.Node.Cells("cCategoryID").Text