473,395 Members | 1,571 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,395 software developers and data experts.

Hashtable and TreeView ?

I am trying to fill the treeview in VB.Net 2005 with Hashtable with the
following code.

my field(0)=emp id
my filed(1)=emp name
my field(2)=manager id
Dim MyNodes As New Hashtable()

Dim node As New TreeNode

Dim dsRow as Datarow

For Each dsRow In ds1.Tables(0).Rows

If IsDBNull(dsRow("MgrID")) Then

Me.TreeView1.Nodes.Add(dsRow("EmpName"))

mynodes.add(dsrow("EmpID"),dsrow("EmpName"))
Else

DirectCast(MyNodes(dsRow("Mgr")), TreeNode).Add(dsRow("Ename")) <-------
this line giving error

End If

Next

Please advise what am I missing ?

Best Regards,

Luqman


Nov 7 '06 #1
1 1698
Luqman wrote:
I am trying to fill the treeview in VB.Net 2005 with Hashtable with the
following code.
.. . .
DirectCast(MyNodes(dsRow("Mgr")), TreeNode).Add(dsRow("Ename")) <-------
this line giving error
.. . .
Please advise what am I missing ?
The actual error message that's causing you trouble?

I'm /guessing/ it's something like this :

1) MyNodes does not contain the required Manager (it's a little unclear
whether you key these by Mgr or MgrId, but anyway), so

MyNodes( dsRow.Item("Mgr").ToString() )

is returning a Null Reference and calling [null].Add doesn;t work very
well.
Question: Do you /really/ need to load the entire tree in one go?

Personally, I would load just the /Managers/ at the root level and then,
as the user expands each of these, go and retrieve the employee list for
/just/ that manager. It's unlikely that any one user will need to see
/everyone/ all in one go.

HTH,
Phill W.
Nov 8 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Brian | last post by:
I'm reasonably new to C#, and using a class containing a hashtable collection to feed a treeview. My problem is that I can't pull the data from the hashtable! Here's the code I have: if...
5
by: francois | last post by:
First of all I would to to apologize for resending this post again but I feel like my last post as been spoiled Here I go for my problem: Hi, I have a webservice that I am using and I would...
5
by: Cyrus | last post by:
I have a question regarding synchronization across multiple threads for a Hashtable. Currently I have a Threadpool that is creating worker threads based on requests to read/write to a hashtable....
8
by: SenthilVel | last post by:
how to get the corresponding values for a given Key in hashtable ??
33
by: Ken | last post by:
I have a C# Program where multiple threads will operate on a same Hashtable. This Hashtable is synchronized by using Hashtable.Synchronized(myHashtable) method, so no further Lock statements are...
16
by: Sreekanth | last post by:
Hello, Is there any better collection than HashTable in terms of performance, when the type of the key is integer? Regards, Sreekanth.
3
by: Fred | last post by:
I'm trying to build a hashtable and a arraylist as object value I'm not able to retrieve stored object from the hashtable. Hashtable mp = new Hashtable(); // THE HASHTABLE ArrayList...
2
by: PAzevedo | last post by:
I have this Hashtable of Hashtables, and I'm accessing this object from multiple threads, now the Hashtable object is thread safe for reading, but not for writing, so I lock the object every time I...
2
by: archana | last post by:
Hi all, I am having one confusion regarding hashtable. I am having function in which i am passing hashtable as reference. In function i am creating one hashtable which is local to that...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.