• 040. asp.netWeb中TreeView控件绑定XML文件


    xml文件格式:

    <?xml version="1.0" encoding="utf-8" ?>
    <sitemap title="进销存管理中心" value="a0" description="进销存管理中心" imgUrl="~/Themes/Images/Navigation/Cube.bmp">
    
      <sitefolder url="" title="系统设置" value="d1"  description="系统设置" imgUrl="~/Themes/Images/Navigation/folder.gif">
        <sitenode url="" value="d2" title="部门设置"  description="部门设置"  target="_self" imgUrl="~/Themes/Images/Navigation/page.gif"/>
        <sitenode url="" value="d3" title="数据字典设置"  description="数据字典设置"  target="_self" imgUrl="~/Themes/Images/Navigation/page.gif"/>
      </sitefolder>
    
    
      <sitefolder url="" title="职责范围" value="d1"  description="职责范围" imgUrl="~/Themes/Images/Navigation/folder.gif">
        <sitenode url="" value="d2" title="经理职责"  description="经理职责"  target="_self" imgUrl="~/Themes/Images/Navigation/page.gif"/>
        <sitenode url="" value="d3" title="门卫职责"  description="门卫职责"  target="_self" imgUrl="~/Themes/Images/Navigation/page.gif"/>
      </sitefolder>
    
    </sitemap>

    拖动一个TreeViee控件到界面:

    选择或创建一个数据源, 编辑TreeNode到数据源的绑定:

    aspx中对应的代码:

    <div style="height: 495px; overflow: auto;  100%;">
                                                <asp:TreeView ID="tvNavigation" runat="server" ExpandDepth="5" Width="100%" SkinID="MSDN"
                                                    DataSourceID="treeSource">
                                                    <DataBindings>
                                                        <asp:TreeNodeBinding DataMember="sitemap" ImageUrlField="imgUrl" SelectAction="Expand"
                                                            TextField="title" ToolTipField="description" ValueField="value" />
                                                        <asp:TreeNodeBinding DataMember="sitefolder" ImageUrlField="imgUrl" SelectAction="Expand"
                                                            TextField="title" ToolTipField="description" ValueField="value" />
                                                        <asp:TreeNodeBinding DataMember="sitefolder" ImageUrlField="imgUrl" SelectAction="Expand"
                                                            TextField="title" ToolTipField="description" ValueField="value" />
                                                        <asp:TreeNodeBinding DataMember="sitefolder" ImageUrlField="imgUrl" SelectAction="Expand"
                                                            TextField="title" ToolTipField="description" ValueField="value" />
                                                        <asp:TreeNodeBinding DataMember="sitenode" ImageUrlField="imgUrl" NavigateUrlField="url"
                                                            TextField="title" ToolTipField="description" ValueField="value" />
                                                    </DataBindings>
                                                </asp:TreeView>
                                                <asp:XmlDataSource ID="treeSource" runat="server" DataFile="~/Themes/Xml/SiteMap.xml">
                                                </asp:XmlDataSource>
                                            </div>
  • 相关阅读:
    Cookie工具类
    验证工具类
    压缩工具类
    一次外企QQ面试
    利用Referer请求头阻止"盗链"
    servlet中ServletConfig的使用
    jquery插件制作
    jQuery选择器总结(转)
    js文件加载执行顺序
    mysql有关问题之:the security settings could not be applied to
  • 原文地址:https://www.cnblogs.com/wxylog/p/6197235.html
Copyright © 2020-2023  润新知