TreeNodeBinding问题

时间:2012-03-23 15:41:45

标签: c# asp.net dotnetnuke treenode

我有一个页面,其中包含在该公司工作的人员的树状目录。最初打开节点的唯一方法是点击小+/-但是当你到达最后一级时,这个人的名字就在那里,然后可以点击他们的生物页面。我已经将它修复到文本也将扩展节点的位置,但现在名称不再可点击了。它仍然具有“链接”外观(蓝色,带下划线,悬停时变为红色)但图标保持不变并且不会转向手指。提前谢谢!

以下是页面上的代码......

<%@ Control language="C#" Inherits="Modules.PeopleNav.PeopleByAlpha" CodeFile="PeopleByAlpha.ascx.cs" AutoEventWireup="true"%>
<%@ Register TagPrefix="dnn" TagName="Audit" Src="~/controls/ModuleAuditControl.ascx" %>
<asp:TreeView ID="TreeView1" runat="server" DataSourceID="XmlDataSource1" 
    ExpandDepth="1" onselectednodechanged="TreeView1_SelectedNodeChanged" OnTreeNodeDataBound="TreeView1_TreeNodeDataBound">
     <DataBindings>
     <asp:TreeNodeBinding DataMember="Person" ValueField="Value"  TextField="Name">
      </asp:TreeNodeBinding> 
      <asp:TreeNodeBinding DataMember="AlphaBreak"  TextField="Name">
      </asp:TreeNodeBinding> 
      <asp:TreeNodeBinding DataMember="PeopleAlpha" TextField="Name">
      </asp:TreeNodeBinding>
   </DataBindings> 
</asp:TreeView><br />

<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/Portals/0/Docs/PeopleAlpha.xml"></asp:XmlDataSource>

背后的代码......

   protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
{
    String sURL = TreeView1.SelectedNode.Value.ToString();
    if (sURL.Length > 5)
    {
        String sExt = sURL.Substring(sURL.Length - 4, 4);
        if (sExt == "aspx")
        {
            Response.Redirect(sURL);
        }
    }
}
          protected void TreeView1_TreeNodeDataBound(object sender, TreeNodeEventArgs e)
{
    e.Node.SelectAction = TreeNodeSelectAction.Expand;
}

1 个答案:

答案 0 :(得分:1)

我猜你应该设置节点的NavigateUrl属性:

protected void TreeView1_TreeNodeDataBound(object sender, TreeNodeEventArgs e)
{
  e.Node.SelectAction = TreeNodeSelectAction.Expand;
  e.Node.NavigateUrl = // extract the url from your e.Node.DataItem
}

这样,我也认为你不再需要TreeView1_SelectedNodeChanged了