Link to home
Start Free TrialLog in
Avatar of nsfranklin
nsfranklinFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Treeview PopulateOnDemand fails

Hi

Can someone tell me why I cannot get this to work. The populate on demand function does not trigger

Here is the aspx code

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TreeView ID="TreeView1" runat="server" ImageSet="Arrows">
            <ParentNodeStyle Font-Bold="False" />
            <HoverNodeStyle Font-Underline="True" ForeColor="#5555DD" />
            <SelectedNodeStyle Font-Underline="True" ForeColor="#5555DD" HorizontalPadding="0px"
                VerticalPadding="0px" />
            <Nodes>
                <asp:TreeNode Text="Available devices" Value="0" PopulateOnDemand="True"></asp:TreeNode>
            </Nodes>
            <NodeStyle Font-Names="Verdana" Font-Size="8pt" ForeColor="Black" HorizontalPadding="5px"
                NodeSpacing="0px" VerticalPadding="0px" />
        </asp:TreeView>
   
    </div>
    </form>
</body>
</html>

Here is the Code behind.

Partial Class _Default
    Inherits System.Web.UI.Page
   
    Protected Sub TreeView1_TreeNodePopulate(ByVal sender As Object, ByVal e As TreeNodeEventArgs)
        Select Case e.Node.Depth
            Case 0
                Response.Write(e.Node)
                Exit Sub
            Case 1
                Response.Write(e.Node)
                Exit Sub
        End Select
    End Sub

any help would be appreciated. Thanks
ASKER CERTIFIED SOLUTION
Avatar of TSmooth
TSmooth

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nsfranklin

ASKER

Hi

Thanks for that, new code is
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" action="Default.aspx" runat="server">
   
    <div>
                <asp:TreeView ID="TreeView1" SkinId="Simple" Width="250" ExpandDepth="0" runat="server" AutoGenerateDataBindings="False">
          <Nodes>
            <asp:TreeNode Text="Inventory" SelectAction="SelectExpand" PopulateOnDemand="True" Value="Inventory"/>
            </asp:TreeNode>
          </Nodes>
        </asp:TreeView>

   
    </div>
    </form>
</body>
</html>

Code behind is

    Protected Sub TreeView1_TreeNodePopulate(ByVal sender As Object, ByVal e As TreeNodeEventArgs) Handles TreeView1.TreeNodePopulate
        Select Case e.Node.Depth
            Case 0
                Response.Write(e.Node.ToString)
                Exit Sub
            Case 1
                Response.Write(e.Node.ToString)
                Exit Sub
        End Select
    End Sub

Why can I only click on the node once to trigger the treenodepopulate, the page re-displays with the + missing and subsequent clicks to not show a response.
Hi

Further to the above, my error, problem solved and points awarded for guidance.

Thanks