Solved

[VB.NET] TreeView event SelectedNodeChange fires twice

Posted on 2009-05-19
3
1,000 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 125 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 125 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

717 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