Dynamically populating and expanding TreeView from button click...

Discussion in 'ASP .Net Web Controls' started by John Roper, Jun 15, 2005.

  1. John Roper

    John Roper Guest

    Hi,

    I have a tree control using Microsoft.Web.UI.WebControls.TreeView. We use
    this to display a file/folder hierarchy. We only populate the top level on
    page load, but we do add a single node for every folder with the text
    "Working...". When a folder is opened, the Working... is displayed and then
    we populate the nodes in the expand handler and everything works.

    I have now added a button to populate and expand to a sub-file/folder. I
    need to clear out the "Working" text and then populate with the real data. I
    use ...Nodes.Clear() to do this, before adding in the new nodes. All my code
    appears to work, but after my button click handler has completed I get a
    NullReferenceException from System.UI.Control.OnBubbleEvent(Object source,
    EventArgs args) [from RaiseBubbleEvent, OnCommand, RaisePostBackEvent,
    ProcessRequestMenu).

    If I remove the Nodes.Clear() everything works (although the Working...
    nodes are left of course). Can anyone explain what's going on and what I
    should do to avoid this exception please?

    Thanks in advance

    John Roper
    John Roper, Jun 15, 2005
    #1
    1. Advertising

  2. John Roper

    Harolds Guest

    One of the reasons that the control is not supported I assume.
    Try:
    Treeviewname.Nodes.RemoveAt(0)
    instead of clear

    "John Roper" wrote:

    > Hi,
    >
    > I have a tree control using Microsoft.Web.UI.WebControls.TreeView. We use
    > this to display a file/folder hierarchy. We only populate the top level on
    > page load, but we do add a single node for every folder with the text
    > "Working...". When a folder is opened, the Working... is displayed and then
    > we populate the nodes in the expand handler and everything works.
    >
    > I have now added a button to populate and expand to a sub-file/folder. I
    > need to clear out the "Working" text and then populate with the real data. I
    > use ...Nodes.Clear() to do this, before adding in the new nodes. All my code
    > appears to work, but after my button click handler has completed I get a
    > NullReferenceException from System.UI.Control.OnBubbleEvent(Object source,
    > EventArgs args) [from RaiseBubbleEvent, OnCommand, RaisePostBackEvent,
    > ProcessRequestMenu).
    >
    > If I remove the Nodes.Clear() everything works (although the Working...
    > nodes are left of course). Can anyone explain what's going on and what I
    > should do to avoid this exception please?
    >
    > Thanks in advance
    >
    > John Roper
    Harolds, Jun 15, 2005
    #2
    1. Advertising

  3. John Roper

    John Roper Guest

    RE: Dynamically populating and expanding TreeView from button clic

    Thanks for taking the time to reply.... I had already tried that. In fact I
    tried commenting out all my code and it still happened. So I rebooted and now
    everything works fine. Has anyone come across this sort of behaviour?
    John Roper, Jun 15, 2005
    #3
  4. John Roper

    Harolds Guest

    RE: Dynamically populating and expanding TreeView from button clic

    Yes, I have had strange things start happening, which went away after a
    reboot, many times.

    "John Roper" wrote:

    > Thanks for taking the time to reply.... I had already tried that. In fact I
    > tried commenting out all my code and it still happened. So I rebooted and now
    > everything works fine. Has anyone come across this sort of behaviour?
    >
    Harolds, Jun 15, 2005
    #4
    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. Purvi T
    Replies:
    0
    Views:
    829
    Purvi T
    Oct 19, 2004
  2. volts
    Replies:
    0
    Views:
    497
    volts
    Apr 7, 2004
  3. Amy
    Replies:
    0
    Views:
    974
  4. chandrajit_in
    Replies:
    0
    Views:
    1,682
    chandrajit_in
    Jan 3, 2008
  5. JamesHead

    Treeview Client side expanding and collapsing of nodes

    JamesHead, Jan 24, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    201
    JamesHead
    Jan 24, 2005
Loading...

Share This Page