?
Solved

[VB.NET] TreeView event SelectedNodeChange fires twice

Posted on 2009-05-19
3
Medium Priority
?
1,003 Views
Last Modified: 2012-05-07
On a webpage I have a TreeView which works together with a DetailsView (for details about the selected item in the TreeView) and a GridView (to display a list of child records for the selected item in the TreeView).

To be able to update the DetailsView and the GridView when the selection changes in the TreeView, I trap the SelectedNodeChange event for the TreeView.

Now it turns out that this SelectedNodeChange event is always fired twice, and thus the DetailsView and the GridView are populated twice as well.

What might be the reason for this double event firing?

Protected Sub wsTreeView_SelectedNodeChange(ByVal sender As TreeView, ByVal e As EventArgs) Handles wsTreeView.SelectedNodeChanged
 
        ' refill GridView for newly selected TreeView branche
        wsTreeGridView.ResetFilter()
        FillTreeGrid(sender.SelectedValue, False)
 
        ' bind DetailsView again in read-only mode
        wsTreeDetailsView.ChangeMode(DetailsViewMode.ReadOnly)
        wsTreeDetailsView.PrimaryKeyValue = Me.SelectedTreeItemID
        BindCategoryDetailsView()
 
    End Sub

Open in new window

0
Comment
Question by:MarjaR
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 4

Accepted Solution

by:
Nikkoli earned 500 total points
ID: 24421571
Do you register the event somewhere else in your code?

Having "Handles wsTreeView.SelectedNodeChanged" takes care of registering, so if you also create an event handler you end up with 2 registrations and therefore 2 events.
0
 
LVL 4

Assisted Solution

by:rdoran0928
rdoran0928 earned 500 total points
ID: 24421649
If you have OnSelectedNodeChanged in your .aspx file like the following, the event will fire twice:

        <asp:TreeView ID="wsTreeView" runat="server" OnSelectedNodeChanged="wsTreeView_SelectedNodeChange">
        </asp:TreeView>
0
 
LVL 1

Author Closing Comment

by:MarjaR
ID: 31582968
You both hit the nail right on the nose. Thank you!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question