asp.net中的TreeView:如何在treeview中的子节点中插入两列?

时间:2011-08-03 11:34:34

标签: c# asp.net treeview

我正在开发一个项目。在那里,我想在treeview的子节点中添加2列。我正在使用C#.NET。我怎么能得到它?

抱歉我的英文。

我想要跟随

     + Parent Node
         - Child Node [Text] [Button]  
         - Child Node [Text1] [Button1]
         - Child Node [Text2] [Button2]

我可以这样做吗?

由于 RedDevils

1 个答案:

答案 0 :(得分:0)

DataSet dtTree = ObjUser.GetAllClientGroupandList();

         TreeView1.Nodes.Clear();

         if (dtTree != null)   
        {
            // Create DataRelation.................  
            DataRelation rel = new DataRelation("ClientCategory", dtTree.Tables[0].Columns["TPAClientGroupId"],
            dtTree.Tables[1].Columns["TPAClientGroupId"], false);
            rel.Nested = true;

            dtTree.Relations.Add(rel);
             // Set the Attribute here .........................
            foreach (DataColumn dc in dtTree.Tables[0].Columns)
            {
                dc.ColumnMapping = MappingType.Attribute;
            }
            foreach (DataColumn dc in dtTree.Tables[1].Columns)
            {
                dc.ColumnMapping = MappingType.Attribute;
            }

           // xml decleartion ......................................
            XmlDataSource xmlD = new System.Web.UI.WebControls.XmlDataSource();


            xmlD.ID = "XmlDataSource1";
            // Call GetXml and assign to xml data source. 
            XmlDataSource1.Data = dtTree.GetXml();


        }

TreeView1.Nodes.Clear(); if (dtTree != null) { // Create DataRelation................. DataRelation rel = new DataRelation("ClientCategory", dtTree.Tables[0].Columns["TPAClientGroupId"], dtTree.Tables[1].Columns["TPAClientGroupId"], false); rel.Nested = true; dtTree.Relations.Add(rel); // Set the Attribute here ......................... foreach (DataColumn dc in dtTree.Tables[0].Columns) { dc.ColumnMapping = MappingType.Attribute; } foreach (DataColumn dc in dtTree.Tables[1].Columns) { dc.ColumnMapping = MappingType.Attribute; } // xml decleartion ...................................... XmlDataSource xmlD = new System.Web.UI.WebControls.XmlDataSource(); xmlD.ID = "XmlDataSource1"; // Call GetXml and assign to xml data source. XmlDataSource1.Data = dtTree.GetXml(); }