Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
385
Nodes Does Not Show Up
posted

This is my ASP code. I just took it from a sample:

<ignav:UltraWebTree ID="AccessTreeView" runat="server" Cursor="Default" ForeColor="Black"

Font-Size="8pt" Font-Names="Verdana" BorderColor="Pink" BorderStyle="Dashed" Height="400px"

Width="300px" Indentation="20" WebTreeTarget="ClassicTree" LoadOnDemand="Manual"

CompactRendering="False" EnableViewState="False" SingleBranchExpand="True" OnDemandLoad="AccessTreeView_DemandLoad">

<SelectedNodeStyle Cursor="Hand" CssClass="SelectClass"></SelectedNodeStyle>

<HoverNodeStyle Cursor="Hand" CssClass="Hover"></HoverNodeStyle>

<NodePaddings Left="5px"></NodePaddings>

<Padding Bottom="2px" Left="2px" Top="2px" Right="2px"></Padding>

<Levels>

<ignav:Level Index="0"></ignav:Level>

<ignav:Level Index="1"></ignav:Level>

</Levels>

<NodeMargins Top="2px"></NodeMargins>

<Styles>

<ignav:Style Cursor="Hand" ForeColor="Black" BackColor="OldLace" CssClass="HiliteClass">

</ignav:Style>

<ignav:Style BorderWidth="1px" BorderColor="DarkGray" BorderStyle="Solid" BackColor="Gainsboro"

CssClass="Hover">

<Padding Bottom="2px" Left="2px" Top="2px" Right="2px"></Padding>

</ignav:Style>

<ignav:Style ForeColor="White" BackColor="#333333" CssClass="SelectClass">

<Padding Bottom="2px" Left="2px" Top="2px" Right="2px"></Padding>

</ignav:Style>

</Styles>

</ignav:UltraWebTree>

This is my Page_Load code:

var AccessControlPopup = (PopupControl)RecordFormView.FindControl("AccessControlPopup");

var AccessTreeView = (UltraWebTree)AccessControlPopup.FindControl("AccessTreeView");

AccessTreeView.Visible = true;

var rootAccessGroups = GetChildAccessGroups("0");foreach (var accessGroup in rootAccessGroups)

{

var accessGroupNode = AccessTreeView.Nodes.Add(accessGroup.Name);

accessGroupNode.DataKey = accessGroup.AccessGroupKey.ToString();

accessGroupNode.ShowExpand =
true;

}

AccessTreeView.DataBind();

AccessTreeView.ExpandAll();

When I step through the code, I clearly see that 1 node is being added to the collection  AccessTreeView.Nodes. However, when the tree view is displayed, it is completely empty.

This is my DemandLoad code, however it is not being hit so I think it is irrelevent:

protected void AccessTreeView_DemandLoad(object sender, WebTreeNodeEventArgs e)

{

foreach (var childAccessGroup in GetChildAccessGroups((string)e.Node.DataKey))

{

var childAccessGroupNode = e.Node.Nodes.Add(childAccessGroup.Name);

childAccessGroupNode.DataKey = childAccessGroup.AccessGroupKey.ToString();

childAccessGroupNode.ShowExpand =
true;

}

}

Parents
No Data
Reply
  • 28464
    posted

    Hello,

    I think the problem here is calling  AccessTreeView.DataBind() immediately after adding the node. The treeview supports bound and unbound modes - adding nodes directly to the controls collection is unbound mode, while calling DataBind() is bound mode and expects setting DataSource or DataSourceID properties. Calling DataBind() with empty DataSource/DataSourceID essentially clears the nodes.

    I think if you are adding nodes directly to the nodes collection, you do not need to call DataBind() so removing the line should hopefully address the problem.

Children