problem with clicking on already selected node in TreeView

Discussion in 'ASP .Net Web Controls' started by Nadav Popplewell, Mar 28, 2007.

  1. Hi Everybody,

    I've got a problem with handling the postback when clicking on already
    selected node in treeview:
    If you click on a non selected tree node then the SelectedNodeChanged is
    called,
    but if you click on the selected tree node then a postback is generated but
    no event is called.
    Why is this?
    And How do I handle it?
    I know I can use postEventSourceID/postEventArgumentID to get the
    information from the Request, but I'm not really supposed to use these right?

    Thanks,
    Nadav
    Nadav Popplewell, Mar 28, 2007
    #1
    1. Advertising

  2. Hi Nadav,

    I think this is by design behavior that this event will only get fired if
    the selected node is really "changed" (different with previous selected
    node).

    Could you please tell me what are you doing in SelectedNodeChanged event?
    Based on the actual requirement, we may have other place to do the job.

    Regards,
    Walter Wang (, remove 'online.')
    Microsoft Online Community Support

    ==================================================
    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.
    ==================================================

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Walter Wang [MSFT], Mar 28, 2007
    #2
    1. Advertising

  3. Hi Walter,

    It's a bit complicated.
    I've got a GridView where I change the row in the RowDataBound event.
    If I don't DataBind the GridView I don't see the row properly.
    But I don't want to DataBind the GridView on every postback because I've run
    into problems with event handling of controls in the GridView templates if I
    DataBind the GridView several times.

    I think that if clicking on the selected node should have no effect then it
    sould not generate a postback.
    It it should have an effect then there should be an event handler to handle
    it.
    The fact that it performs a postback but there is no event handler for the
    postback does not make sense to me.

    Nadav
    Nadav Popplewell, Mar 28, 2007
    #3
  4. Hi Nadav,

    Thanks for your quick reply.

    Yes I understand your concern here. However, since different nature between
    WinForm and ASP.NET application, we could only know that the selected node
    is not changed after the postback is issued.

    Based on my understanding, you're currently determining whether or not to
    bind a GridView in the TreeView's SelectedNodeChanged event? Does that mean
    the GridView only gets databinding when TreeView's SelectedNode is not
    null? If this is the case, I think you can call GridView.DataBind() in
    Page_Load whenever TreeView.SelectedNode is not null. What do you think?

    Regards,
    Walter Wang (, remove 'online.')
    Microsoft Online Community Support

    ==================================================
    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.
    ==================================================

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Walter Wang [MSFT], Mar 28, 2007
    #4
  5. Hi Walter,

    > Based on my understanding, you're currently determining whether or not to
    > bind a GridView in the TreeView's SelectedNodeChanged event? Does that mean

    Yes, if the SelectedNodeChanged I update the information displayed and
    databind the gridview. If the selected node didn't change OR if another event
    handler is going to databind the gridview I don't want to DataBind again in
    the Page_Load().

    > the GridView only gets databinding when TreeView's SelectedNode is not
    > null? If this is the case, I think you can call GridView.DataBind() in
    > Page_Load whenever TreeView.SelectedNode is not null. What do you think?


    I wish it was that simple. The SelectedNodeChanged (or any other event) is
    NOT called when clicking on the currently selected node so I have to handle
    it in the Page_Load event, however in order to detect that the postback is
    caused by clicking on a node in the TreeView I have to access the __Event*
    form fields which I'm not supposed to do.
    Another problem I've discovered is that when clicking on a non selected node
    by the time Page_Load is called the SelectedNode property is already updated
    so I have to save the old selected node path in the view state so I can
    deteremine in the Page_Load (which is called before the SelectedNodeChanged)
    if the postback is caused by clicking on the selected node or on a different
    node.
    It a real pity that the TreeView does not perform these tasks for you...

    Nadav
    Nadav Popplewell, Mar 29, 2007
    #5
  6. Hi Nadav,

    Yes we have two issues of the TreeView here:

    1) The SelectedNodeChanged event is only fired when the node is really
    changed: it will not fire if you clicking on the already selected node but
    the postback is still taken place.

    2) The previously selected node is not stored on the TreeView, you have to
    do that yourself.

    I fully understand that these issues caused inconvenience for your project.
    However, please rest assured that we're continuously improving our products
    and it's customer like you help us to do better with such feedback. I will
    surely help forward your feedback to product team. You're also welcome to
    submit your feedback at
    http://connect.microsoft.com/Main/content/content.aspx?ContentID=2220 which
    is monitored by our product team directly and you will also receive direct
    response from them.

    For now, we have to use some workaround to deal with these limitations,
    please feel free to let me know if you need further information for the
    workaround. Thanks.

    Regards,
    Walter Wang (, remove 'online.')
    Microsoft Online Community Support

    ==================================================
    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.
    ==================================================

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Walter Wang [MSFT], Mar 30, 2007
    #6
  7. Hi,

    I am facing this same problem. Has there been any updates from
    Microsoft to handle this or does it have to be handled in the Page_Load
    event? Also can you provide me code example on how to handle this?


    *** Sent via Developersdex http://www.developersdex.com ***
    LaBrina Loving, Apr 3, 2007
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    1,399
  2. Replies:
    3
    Views:
    9,030
    Daniel TIZON
    Dec 17, 2005
  3. Tjerk Wolterink
    Replies:
    2
    Views:
    1,399
    Dimitre Novatchev
    Aug 24, 2006
  4. Tor Inge Rislaa
    Replies:
    0
    Views:
    829
    Tor Inge Rislaa
    Feb 5, 2007
  5. William Main

    Fixed bug in IE Treeview Webcontrol when clicking on leaf node.

    William Main, Feb 1, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    256
    William Main
    Feb 1, 2005
Loading...

Share This Page