TreeView SelectedNodeChanged Triggers Parent's TreeNodePopulate?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dmeglio@gmail.com

    #1

    TreeView SelectedNodeChanged Triggers Parent's TreeNodePopulate?

    I have a treeview control. The "root" elements and the 2nd level
    elements are set to PopulateOnDeman d. All is fine, my TreeNodePopulat e
    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
    PopulateOnDeman d=false. At the 3rd level, my nodes are set to
    SelectAction = SelectExpand. When I click on one of them, my
    SelectedNodeCha nged event does fire, but AFTER the TreeNodePopulat e
    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!
  • dmeglio@gmail.com

    #2
    Re: TreeView SelectedNodeCha nged Triggers Parent's TreeNodePopulat e?

    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 "
    PopulateNodesFr omClient="true"
    OnTreeNodePopul ate="TreeView1_ TreeNodePopulat e">
    </asp:TreeView>
    In codebehind:
    protected void Page_Load(objec t sender, EventArgs e)
    {
    TreeNode node = new TreeNode();
    node.Text = "test1";
    node.PopulateOn Demand=true;
    TreeView1.Nodes .Add(node);
    }

    protected void TreeView1_TreeN odePopulate(obj ect sender,
    TreeNodeEventAr gs e)
    {
    TreeNode node = new TreeNode();
    node.SelectActi on = TreeNodeSelectA ction.SelectExp and;
    node.Text = "test2";
    e.Node.ChildNod es.Add(node);
    }

    Comment

    Working...