[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

[VB.NET] TreeView event SelectedNodeChange fires twice

Posted on 2009-05-19
3
Medium Priority
?
1,021 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
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses
Course of the Month18 days, 12 hours left to enroll

834 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