Solved

[VB.NET] TreeView event SelectedNodeChange fires twice

Posted on 2009-05-19
3
984 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 125 total points
Comment Utility
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
Comment Utility
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
Comment Utility
You both hit the nail right on the nose. Thank you!
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
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 video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

728 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now