473,385 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to generate TreeView using DataReader?

126 100+
Hullo Awesome Friends,

WINDOW Based Application using VBNET2008, DataReader and TreeView Control Nodes
I need your help, Please help me.

I am using TreeView controls and having problem writing the coding as I have not done it before.

Listed beow are the SQL String and the result of it. And also the Proposed Desired display on TreeView.

SQL String :
SELECT OrderID, OrderDate ProductID
FROM Invoices WHERE (CustomerID = N'Chops') Order by OrderID, Orderdate

Result of SQL String
OrderId OrderDate ProdID
10254 11/07/1996 74
10254 11/07/1996 24
10254 11/07/1996 55
10254 23/07/1996 105
10254 23/07/1996 96
10254 25/07/1996 82

10370 03/12/1996 74
10370 03/12/1996 1
10370 03/12/1996 64
10370 03/12/1996 56

10519 28/04/1997 10
10519 28/04/1997 60

---------------------------------------------------------
Proposal Desired TreeView Display Format during RunTime
How to use DataReader (While DR.READ()) in order to create the structure listed below
10254
|______11/07/1996
|__________74
|__________24
|_________ 55
|______ 23/07/1996
|_________ 105
|_________ 96
|_________ 82


10370
|______03/12/1996
|_________74
|_________1
|_________64
|_________56

10519
|_______28/04/1997
|________

Thank you very much for your help.
Feb 8 '11 #1
1 2473
pod
298 100+
what you might want to do is add the parent nodes (Order ID) in the _Load method and add the child nodes in _BeforeExpand method
Expand|Select|Wrap|Line Numbers
  1. (_Load method)
  2. nodecnt = 0
  3. While reading [distinct_Order_ID result set]
  4.    myTreeView.Nodes.Add(Order ID)
  5.    myTreeView.Nodes(nodecnt).Nodes.Add("Empty")
  6.    nodecnt += 1
  7. Loop
  8.  
  9. (BeforeExpand method)
  10. If e.Node.Level = 0 Then
  11.    e.Node.Nodes.Clear()
  12.    nodecnt = 0
  13.    <-- create query based on the selected Order ID "e.Node.Name"-->
  14.    While reading [invoices_selected_Order_ID result set]
  15.       <-- firstencounter-->
  16.       'here you have to put in some conditional stuff to add only and Order Date node when first encountered
  17.       if firstencounter then
  18.           Me.edaTreeView.Nodes(e.Node.Name).Nodes.Add(Order Date)
  19.       end if
  20.       <-- end of firstencounter-->
  21.       Me.edaTreeView.Nodes(e.Node.Name).Nodes(nodecnt).Add(ProductID)
  22.       <-- firstencounter-->
  23.       if firstencounter then
  24.          nodecnt += 1
  25.       end if
  26.       <-- end of firstencounter-->
  27.    Loop
  28.  
  29. End If
  30. Loop
  31.  
Feb 8 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Ravi | last post by:
i tried with MS treeview control but i am unable to implement all the requirements.This requiement like when user login will generate the menu and display it. After that we need to Add or remove...
1
by: Aleksey | last post by:
Hi, All! I have a problem with TreeView component. My TreeView consists of two nodes Node1 and Node2. On click of right mouse button TreeView has event. In this event I check wich node is...
0
by: pedaammulu | last post by:
Hi, I have put up a page which can help you to understand the workings of how to access SQL data using VB.Net. http://www.vkinfotek.com/datareader.html All info on the page and site is to...
1
by: nasirmajor | last post by:
Dear All, im fetching record from database using datareader, and is displaying them in the textboxes. when user change the text fields and then presses the update button the record should be...
1
by: watsod1 | last post by:
Hello, This is my first post, Hello to all. This also a test post to make sure that I am doing the right thing and following rules etc. I have been searching for a way to make the treeview...
2
by: bindu123 | last post by:
Hi All, I have to generate a line chart in C on windows, using distance in the X-axis and throughput in Y-axis. Is it possible to generate charts using C programming in windows ? and i also i...
4
by: sreedevipd | last post by:
Hi all, I need to create a treeview using javascript and xml ...i am stuck with the same issue ..can anybody help... I am using C#Asp.net Thanks in Advance sridevi
0
by: Selun | last post by:
Hi all, First of all im not sure if this is the correct section to ask this. Im using C# .NET I m trying to populate a gridview using datareader with the following code protected void...
0
by: Teka Cherenet | last post by:
I am newer for programming world in C# and SQL Server. so I wonder if it is possible to have a sample code which illustrates how to generate report using C# code. thank you
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.