【问题标题】:Nested xml binding to CheckBoxList [duplicate]嵌套 xml 绑定到 CheckBoxList [重复]
【发布时间】:2014-01-22 02:22:15
【问题描述】:

我有一个包含菜单和子菜单的嵌套 xml 文件。我需要在页面加载时将其绑定到 ASP.NET CheckBox 控件。请看下面的代码。

我正在尝试使用下面的 C# 代码进行绑定:

    DataSet ds = new DataSet();
    try
    {

        //Reading the data from  the XML file
        ds.ReadXml(HttpContext.Current.Server.MapPath("~/menu.xml"));
        DataView dataview = ds.Tables[0].DefaultView; 
        BioCheckBoxList.DataSource = dataview ;
        BioCheckBoxList.DataBind();            
     }  

XML:

enter code here
<!--<menu>
  <menuItem text="Home" url="~/Default.aspx?id=e058511b-b7d9-4d39-b194-cf803014777" mid="08f360dc-   a9cf-4724-a595-66f7ca01c04e" predeficon="homeico" />
  <menuItem text="Bio" url="~/Default.aspx"  icon="~/common/theme/smoothadmin/img/cog.png">
    <subMenu>
      <menuItem text="Reg" url="~\Modules\Bio\Reg.aspx"/>
      <menuItem text="Mem" url="~\Modules\Bio\Mem.aspx"/>      
    </subMenu>
  </menuItem>    
  <menuItem text="Por" url="~/Default.aspx?"  icon="~/common/theme/smoothadmin/img/cog.png">
    <subMenu>
      <menuItem text="General">
        <subMenu>
          <menuItem text="Make Appointment" url="~\Modules\Portals\Gen.aspx"/>          
        </subMenu>
      </menuItem>
    </subMenu>
  </menuItem>
</menu>-->

任何帮助将不胜感激。

【问题讨论】:

    标签: c# asp.net xml model-binding


    【解决方案1】:

    虽然你没有说是什么问题,但可能是xml被注释掉了(开头&lt;!--,结尾--&gt;)?

    【讨论】:

      猜你喜欢
      • 2014-02-11
      • 1970-01-01
      • 2012-05-04
      • 1970-01-01
      • 1970-01-01
      • 2017-12-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多