TreeView SelectedNodeChanged Triggers Parent's TreeNodePopulate?

Discussion in 'ASP .Net' started by dmeglio@gmail.com, Aug 4, 2008.

  1. Guest

    I have a treeview control. The "root" elements and the 2nd level
    elements are set to PopulateOnDemand. All is fine, my TreeNodePopulate
    triggers and works. When you click one of those nodes, I load ALL the
    data under it. Meaning children, grandchildren, great grandchildren,
    etc. Hence, those 3rd level and below nodes are
    PopulateOnDemand=false. At the 3rd level, my nodes are set to
    SelectAction = SelectExpand. When I click on one of them, my
    SelectedNodeChanged event does fire, but AFTER the TreeNodePopulate
    fires for the 2nd level node. My question is, why is it loading data
    for a node I didn't even click (the parent of the node I clicked), and
    why is it loading it given that the data is already loaded?

    Is this a bug? Is there a work around? Thank you in advance!
     
    , Aug 4, 2008
    #1
    1. Advertising

  2. Guest

    Sorry I didn't post this at first, but the following code reproduces
    it:
    In aspx:
    <asp:TreeView
    id="TreeView1"
    runat="server"
    ExpandDepth="0"
    ShowLines="true"
    PopulateNodesFromClient="true"
    OnTreeNodePopulate="TreeView1_TreeNodePopulate">
    </asp:TreeView>
    In codebehind:
    protected void Page_Load(object sender, EventArgs e)
    {
    TreeNode node = new TreeNode();
    node.Text = "test1";
    node.PopulateOnDemand=true;
    TreeView1.Nodes.Add(node);
    }

    protected void TreeView1_TreeNodePopulate(object sender,
    TreeNodeEventArgs e)
    {
    TreeNode node = new TreeNode();
    node.SelectAction = TreeNodeSelectAction.SelectExpand;
    node.Text = "test2";
    e.Node.ChildNodes.Add(node);
    }
     
    , Aug 4, 2008
    #2
    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. Andrew Robinson

    TreeView SelectedNodeChanged Event

    Andrew Robinson, Dec 5, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    11,286
    Steven Cheng[MSFT]
    Dec 7, 2005
  2. tanya foster
    Replies:
    1
    Views:
    3,603
    tanya foster
    Jun 5, 2006
  3. =?Utf-8?B?V2lsbGlhbSBTdWxsaXZhbg==?=

    Redirecting in 2.0 TreeView TreeNodePopulate

    =?Utf-8?B?V2lsbGlhbSBTdWxsaXZhbg==?=, Jul 5, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    557
    =?Utf-8?B?V2lsbGlhbSBTdWxsaXZhbg==?=
    Jul 5, 2006
  4. Velislav

    TreeView SelectedNodeChanged event

    Velislav, Nov 24, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    685
    Velislav
    Nov 24, 2006
  5. Alex Diaz
    Replies:
    0
    Views:
    524
    Alex Diaz
    Aug 6, 2010
Loading...

Share This Page