views:

298

answers:

1

I have a tree view like this and i want to navigate to 3 different pages using response .redirect

--machine groups (main)

----dept (Parent)

------xyz (child)

 protected void TreeView2_SelectedNodeChanged(object sender, EventArgs e)
    {
        if (TreeView2.SelectedValue == "Machine Groups")
        {
            Response.Redirect("~/Gridviewpage.aspx");
        }
        else
               switch (e.Node.Depth)
               {
                   case 0:
                       Response.Redirect("~/Machineupdate.aspx?node=" + TreeView2.SelectedNode.Value);
                       break;
                   case 1:
                       Response.Redirect("~/MachineUpdatechild.aspx?node=" + TreeView3.SelectedNode.Value);
                       break;
               }
           }
       }

now if i put EventArgs it points to an error on e.Node that system.EventArgs does not contain definition for Node.

If i replace EventArgs with TreeNodeEventArgs then that error goes but i get an error on compilation.

Compiler Error Message: CS0123: No overload for 'TreeView2_SelectedNodeChanged' matches delegate 'System.EventHandler'

<asp:TreeView ID="TreeView2" runat="server"  OnUnload="TreeViewMain_Unload" 
        ontreenodepopulate="TreeView2_TreeNodePopulate" 
        onselectednodechanged="TreeView2_SelectedNodeChanged">
        <Nodes>
            <asp:TreeNode PopulateOnDemand="True" Text="Machine Groups"
                Value="Machine Groups"></asp:TreeNode>
        </Nodes>
    </asp:TreeView>

Please help me out....

I would also like to kno what is the diff between EventArgs and TreeNodeEventArgs

Thanks

A: 

So, this looks like one of those poor API issues... I would think it reasonable to pass more specific event args here too!

One thing to look at is instead of trying to get the selected node from the event args, try doing the switch on the selected node with TreeView2.SelectedNode.

It looks like you were halfway there already, because you are using that proprerty later on. So, I don't know if there might be an issue you've already found with that but don't mention itabove.

Jim Leonardo