473,395 Members | 1,497 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.

selectednodechanged event on .NET 2.0 treeview problem

Hello,
I have populated a treeview in asp.net 2.0 from an xmldocument. The
treeview structure in the asp web page looks something like...

-orderdata
-order
-lines
-operations
-materials
-material
-partnumber="123"
-description="brass bolt"
-quantity="1"
-type="Job"
-units="grams"
-material
-partnumber="ABC"
-description="plywood"
-quantity="9"
-type="Job"
-units="pounds"
-material
-partnumber="999"
-description="metal frame"
-quantity="2"
-type="Job"
-units="whole"

....

the point is, there are multiple material children to a materials parent.

The treeview is name TreeViewForXml

My selectednodechanged callback begins like..

Protected Sub TreeViewForXml_SelectedNodeChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles TreeViewForXml.SelectedNodeChanged

Dim TextToEdit, StringToParse() As String

HideAllEditFields()

ListBoxForOrderInformation.Items.Add("Selected value=" &
TreeViewForXml.SelectedNode.Value & _
" text=" & TreeViewForXml.SelectedNode.Text)
......

The problem is, sometimes if I click on quantity="2" (or any other quantity
that is not in the first material child of materials), the selectednode(or
the message I get in my listbox) is quantity="1"(or always the quantity node
in the first material child of materials). In the above example, there are
3 material children of materials but there could be 20 material children or
more.

I am seeing this happen if I selected partnumber="999", the TreeviewForXml.
SelectedNode is partnumber="123"(the first child in the list of material
children).

What am I doing wrong to trap selectednode?

I know the TreeNodeCollection.IndexOf(treenode) method will return the first
occurrence of a node if it appears multiple times in the collection.

Is this also the rule with a treeview and selectednode?

thanks.
May 31 '06 #1
1 4723
Good news. Problem solved. =
Some background:

A treenode has two fields that may be set to strings: text and value.

When I was creating my treeview, I was setting the treenode.text field and the treeno=
de.value field to the same string, in this example, =E2=80=9Cmaterial=E2=80=9D.

=
I changed the code used to populate the treeview by using a running counter for each ma=
terial treenode created.

For example,

The first material treenode contained =

treenode.value =3D material1 =

treenode.text =3D material

The second material treenode contained =

treenode.value =3D material2 =

treenode.text =3D material

The 3rd material treenode contained =

treenode.value =3D material3 =

treenode.text =3D material

The nth material treenode contained =

treenode.value =3D materialn =

treenode.text =3D material

=
After I did this, when I selected a partnumber, type, units, etc(children of each mat=
erial node), it did resolved correctly to the treenode I thought I selected.

So this tells me that asp.net 2.0 treeview needs some uniqueness to the VALUE field of=
treenodes for selectedNode to correctly resolve.

=
I also tested not setting the value field to a unique string and setting the text field=
to a unique string and the problem still existed.

=
I just wish this caveat was documented.
Jun 5 '06 #2

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

Similar topics

3
by: serge calderara | last post by:
Dear all, I have a class named for Instance "MyClass" which populate trough an interface a context menu object to the main application. The click event on any of the context menu itemm will be...
0
by: Emerson | last post by:
The following assumes a System.Windows.Forms.DataGrid with a System.Data.DataTable set as the DataSource. I'm programming in C# Here's my scenario I click in a cell on a DataGrid. I enter some...
8
by: Donald Xie | last post by:
Hi, I noticed an interesting effect when working with controls that are dynamically loaded. For instance, on a web form with a PlaceHolder control named ImageHolder, I dynamically add an image...
2
by: Fábio Prado | last post by:
I have one problem with events in a child form. I need raise a event to validate the textbox controls of child form when i click in one existent treeview menu in the Mdi parent and don´t allow that...
4
by: Andrew Robinson | last post by:
I am using a TreeView to perform navigation and have a few nodes that need to generate a popup menu. For this, I use the SelectedNodeChanged event and then add the relevant "window.open" script to...
0
by: stacy | last post by:
My asp.net Web application is written in VB, using VS 2005 with Framework 2.0 I am having trouble with the SelectedNode element. The TreeView is built programmatically and looks like this: -...
0
by: Velislav | last post by:
Hi Quick question: Theoretically, is the SelectedNodeChanged event fired when the currently selected node is actually changed (as the name implies) or when any node is selected, including the...
0
by: Chris | last post by:
I am using CSS adaptors. When I use enen the most basic treeview the SelectedNodeChanged does not fire. Can anyone help, I am totally stuck. I need to use the CSS adaptors to make the site...
1
by: dmeglio | last post by:
I have a treeview control. The "root" elements and the 2nd level elements are set to PopulateOnDemand. All is fine, my TreeNodePopulate triggers and works. When you click one of those nodes, I load...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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
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...
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...

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.