[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

[VB.NET] TreeView event SelectedNodeChange fires twice

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

656 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