473,612 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

selectednodecha nged 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="br ass bolt"
-quantity="1"
-type="Job"
-units="grams"
-material
-partnumber="ABC "
-description="pl ywood"
-quantity="9"
-type="Job"
-units="pounds"
-material
-partnumber="999 "
-description="me tal 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 selectednodecha nged callback begins like..

Protected Sub TreeViewForXml_ SelectedNodeCha nged(ByVal sender As Object,
ByVal e As System.EventArg s) Handles TreeViewForXml. SelectedNodeCha nged

Dim TextToEdit, StringToParse() As String

HideAllEditFiel ds()

ListBoxForOrder Information.Ite ms.Add("Selecte d value=" &
TreeViewForXml. SelectedNode.Va lue & _
" text=" & TreeViewForXml. SelectedNode.Te xt)
......

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 TreeNodeCollect ion.IndexOf(tre enode) 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 4739
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=9Cmateri al=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
1815
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 proceed in the myClass event handler. Actally default event handle has two parameters: Sender and e Actually the context menu is shown in my main application
0
3171
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 text. Before changing to another cell in the DataGrid, I move my mouse pointer off the DataGrid and change the selected item in a ListBox or TreeView. Here's my question Which should fire first, the DataTable's RowChanged/CellChanged event or...
8
4308
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 button at runtime: //----- Code snippet protected System.Web.UI.WebControls.PlaceHolder ImageHolder; private void Page_Load(object sender, System.EventArgs e)
2
1040
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 click event of the menu treeview raise when the event of texbox don´t be validated. Anybody have a solution? Thanks!
4
9394
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 the page using the ClientScript.RegisterStartupScript method. This seems to work fine, but if the user clicks on the same node twice, the event doesn't fire a second time. I assume this is by design as the Node Selection hasn't changed, but...
0
1407
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: - PES +SSI_Engineering +Sensor:2 +Sensor:3 +Sensor:4
0
1480
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 currently selected node (as the documentation implies) The documentation: "The SelectedNodeChanged event is raised when a node is selected in the TreeView control."
0
1352
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 accessible and compliant etc. Here is some sample code. When I put the exact code in a non CSS adaptor website, it works. <asp:TreeView ID="TreeView1" runat="server"> <Nodes> <asp:TreeNode Text="Test" Value="Test"> <asp:TreeNode Text="Test"...
1
4964
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 ALL the data under it. Meaning children, grandchildren, great grandchildren, etc. Hence, those 3rd level and below nodes are PopulateOnDemand=false. At the 3rd level, my nodes are set to SelectAction = SelectExpand. When I click on one of them,...
0
8162
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8105
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8246
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8415
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5532
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4045
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4109
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2550
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1413
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.