您的位置:首页 >综合动态 >

treeview二级节点排序(treeview绑定)

大家好,香香来为大家解答以上的问题。treeview二级节点排序,treeview绑定这个很多人还不知道,现在让我们一起来看看吧!

1、treeview 绑定xml代码如下:                                  101室            102室            103室            104室                                201室            202室            203室            204室                                          101室          102室          103室          104室                          201室          202室          203室          204室                                      101室        102室        103室        104室                    201室        202室        203室        204室                                101室        102室        103室        104室                    201室        202室        203室        204室             protected void Button1_Click(object sender, EventArgs e) { XmlDataSource XmlComputer = new XmlDataSource(); //建立XmlDataSource实例 XmlComputer.ID = "ComputerProducts"; XmlComputer.DataFile = "Computer.xml"; //指定XmlDataSource来源为XML文件 TreeView1.DataSource = XmlComputer;//或是您可以用下列方式声明 //指定TreeView的数据源为XmlComputer //TreeView1.DataSourceID = XmlComputer.UniqueID; //Page.Controls.Add(XmlComputer);//建立根节点 TreeNodeBinding RootBinding = new TreeNodeBinding(); RootBinding.DataMember = "Root"; //指定RootBinding数据成员为Root节点 RootBinding.NavigateUrlField = "url"; //指定RootBinding的NavigateUrl为url RootBinding.TextField = "name"; //指定TextField为name RootBinding.ToolTipField = "describe"; //指定ToolTipField为describe RootBinding.Target = "main"; //将RootBinding加入DataBindings之中 TreeView1.DataBindings.Add(RootBinding); //建立父节点 TreeNodeBinding ParentBinding = new TreeNodeBinding(); ParentBinding.DataMember = "Parent"; ParentBinding.NavigateUrlField = "url"; ParentBinding.TextField = "name"; ParentBinding.ToolTipField = "describe"; ParentBinding.Target = "main"; TreeView1.DataBindings.Add(ParentBinding); //建立子节点(叶节点) TreeNodeBinding ChildBinding = new TreeNodeBinding(); ChildBinding.DataMember = "Child"; ChildBinding.NavigateUrlField = "url"; ChildBinding.TextField = "name"; ChildBinding.ToolTipField = "describe"; ChildBinding.Target = "main"; TreeView1.DataBindings.Add(ChildBinding); //Page.FindControl("Form1").Controls.Add(TreeView1); this.TreeView1.DataBind(); //TreeView进行数据绑定 }xml文件 我是从“上海全鼎软件学院”毕业的————————。

本文到此分享完毕,希望对大家有所帮助。

免责声明:本文由用户上传,如有侵权请联系删除!