不管是treeview控件也好 后台拼接成树也好 JQ也好 统统要...- -希望这个帖子发完 以后CSDN对于树形的疑问直接收藏我这个 高手们 前辈们果断过来围观

解决方案 »

  1.   


    if (!Page.IsPostBack)
            {
                //InitTree(0, null);
                Bing(0, null);
            }private void Bing(int ParentID, TreeNode pNode)
        {
            DataSet ds = Product.Categorys_Get(0, 0, ParentID);
            int num = ds.Tables[0].Rows.Count;
            for (int i = 0; i < num;i++ )
            {
                TreeNode Tn = new TreeNode();
                if (pNode == null)
                {
                    Tn.Text = ds.Tables[0].Rows[i]["Title"].ToString() + "<font color='#003399'>·修改</font>";
                    Tn.Value = ds.Tables[0].Rows[i]["Id"].ToString();
                    TreeCategory.Nodes.Add(Tn);
                    Tn.Expanded = false;
                    Bing(Convert.ToInt32(ds.Tables[0].Rows[i]["Id"].ToString()), Tn);    //再次递归
                }
                else
                {
                    Tn.Text = ds.Tables[0].Rows[i]["Title"].ToString() + "<font color='#003399'>·修改</font>";
                    Tn.Value = ds.Tables[0].Rows[i]["Id"].ToString();
                    pNode.ChildNodes.Add(Tn);
                    Tn.Expanded = false;
                    Bing(Convert.ToInt32(ds.Tables[0].Rows[i]["Id"].ToString()), Tn);    //再次递归
                }
            }
        }
    <asp:TreeView ID="TreeCategory" runat="server" ShowLines="True" CssClass="treelist"
                    ShowCheckBoxes="All" OnSelectedNodeChanged="TreeCategory_SelectedNodeChanged">
                </asp:TreeView>
      

  2.   

    http://zhidao.baidu.com/question/6474488.html
      

  3.   

    SometingJack,我已经看见你吊死在树上很多回了,我看不下去了已经!!!
      

  4.   

    http://www.cnblogs.com/YamatAmain/archive/2011/08/31/2160375.html
      

  5.   

    例子一、http://www.360doc.com/content/09/1202/15/12027_10210280.shtml例子二、http://www.bitscn.com/pdb/dotnet/200904/160583.html例子三、http://hi.baidu.com/459800/blog/item/d4ee7cedf1ce7cddb21cb146.html
      

  6.   

    - - 首先这个帖子不是为我个人 再说CSDN也可以作为你所说的“网上”找下 服务大众 何乐不为呢=- -
      

  7.   

    把数据排好序,按顺序输出出来就是树形的接口
    关键是刚开始的排序,一般用递归读取数据生成视图,或者用内连接和while实现
      

  8.   

    占个位置
    继续努力学习中..........
    顶顶帖子,接分中........顶顶帖子,高手们也请多多赐教
    http://topic.csdn.net/u/20110913/13/59f92d11-1fb0-4b7e-9c4a-e93d8f19c689.html
    http://topic.csdn.net/u/20110611/12/3258c959-4f28-46b7-b5d6-46135d73036b.html
    http://topic.csdn.net/u/20110722/14/89f7440b-c4d7-4c9a-a4bb-a503f5135db2.html
    http://topic.csdn.net/u/20110729/10/a7bfaf06-0cf9-4580-8e91-d4e0b92066c6.html
    http://topic.csdn.net/u/20110811/16/e56e7cc1-d8c9-40af-92e3-c24ca103d17d.html
    http://topic.csdn.net/u/20110830/13/dfae4ca5-d2b9-4889-8a3c-6f7fb61936c9.html
    http://topic.csdn.net/u/20110905/12/a1161adb-8e5d-491a-b302-c9722edf2dab.html
    http://topic.csdn.net/u/20110913/16/2dbcc9db-8f71-40c5-901f-afae9026f7c2.html
    http://topic.csdn.net/u/20110913/13/59f92d11-1fb0-4b7e-9c4a-e93d8f19c689.html
      

  9.   

        Private Property AccFunDataSet As DataSet
            Get
                Dim ds As DataSet            If Session("AccFunctionsDataSet") Is Nothing Then
                    Dim comm As New Common()
                    Dim CodeMain As New MTRC.IRIS.DAL.codeMaintenance()                Try
                        ds = CodeMain.getAccFunctions("", Me.curLanguage)
                        Dim dr As DataRow = ds.Tables(0).NewRow
                        dr("AccessFunctionID") = ""
                        ds.Tables(0).Rows.Add(dr)                    Session("AccFunctionsDataSet") = ds
                    Catch ex As Exception
                        comm.LogEvent(ex.Message, Diagnostics.EventLogEntryType.Error)
                        Throw
                    Finally
                        CodeMain = Nothing
                        comm = Nothing
                    End Try            Else
                    ds = Session("AccFunctionsDataSet")            End If            Return ds
            End Get
            Set(ByVal value As DataSet)
                Session("AccFunctionsDataSet") = Nothing
            End Set
        End Property
        Private Function GetSubAccFunctions(ByVal ParentFunctionID As String, Optional ByVal IncludeEmptyRow As Boolean = False) As DataView        Dim ds As DataSet = AccFunDataSet
            Dim filter As String = "AccessFunctionID='" + ParentFunctionID + "'"
            If IncludeEmptyRow Then
                filter += " Or AccessFunctionID=''"
            End If        Dim dv As DataView = New DataView(ds.Tables(0), filter, "AccessFunctionID ASC", DataViewRowState.CurrentRows)        Return dv    End Function    Private Sub ShowTree()        tvwAccFunction.Nodes.Clear()        Dim RootNode As New System.Web.UI.WebControls.TreeNode()
            RootNode.Text = "IRIS"
            RootNode.Value = "-"        tvwAccFunction.Nodes.Add(RootNode)
            CreateChildTree(RootNode)        RootNode.Select()    End Sub Private Sub CreateChildTree(ByVal ParentNode As System.Web.UI.WebControls.TreeNode)        ParentNode.Expanded = False
            Try
                Dim dv As DataView = GetSubAccFunctions(ParentNode.Value)
                Dim i As Integer
                For i = 0 To dv.Count - 1
                    Dim myTreeNode As New System.Web.UI.WebControls.TreeNode()
                    myTreeNode.Text = dv(i)("AccessFunctionDesc")
                    myTreeNode.Value = dv(i)("AccessSubFunctionID")                ParentNode.ChildNodes.Add(myTreeNode)                If dv(i)("HasChildren") Then
                        CreateChildTree(myTreeNode)
                    End If            Next
            Catch ex As Exception
                Throw
            Finally        End Try
        End Sub    Protected Sub tvwAccFunction_SelectedNodeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles tvwAccFunction.SelectedNodeChanged
            'e.Node
            Dim node As TreeNode = tvwAccFunction.SelectedNode        AccFunction = node.Value
            BindGrid(node.Value)        Me.tvwAccFunction.CollapseAll()        SelectedValuePath = node.ValuePath        ExpandTreeNode(node)
        End Sub    Private Sub ExpandTreeNode(ByVal valuePath As String)
            Dim node As TreeNode = tvwAccFunction.FindNode(valuePath)
            If Not node Is Nothing Then
                ExpandTreeNode(node)
            End If
        End Sub    Private Sub ExpandTreeNode(ByVal node As TreeNode)
            Dim vp As String = node.ValuePath
            Dim pos As Integer = -1
            pos = vp.IndexOf(tvwAccFunction.PathSeparator, pos + 1)
            While pos > 0
                Dim nd As TreeNode = tvwAccFunction.FindNode(vp.Substring(0, pos))
                nd.Expanded = True            pos = vp.IndexOf(tvwAccFunction.PathSeparator, pos + 1)
            End While        node.Expanded = True
            node.Selected = True
        End Sub
      

  10.   

    哇塞 有asp.net版的吗 不是你帖子就沉了 感谢!
      

  11.   


    JQuery zTree
      

  12.   

    话说回来 网上很多树形结构的实现ID和父ID都是  INT类型的字段  现在很多项目都不用INT了 用GUID保证数据的唯一性 GUID有利有弊  当然用它肯定有道理 所以如果有以GUID类型为ID的例子不妨发出来大家一起学习一下
      

  13.   

    有本书叫<锋利的jquery>,里面有很多ajax的例子,返回string,xml,json等示例有好的  这里有下载地址