服务器标记在复选框和itemtemplate上没有很好地形成

本文关键字:很好 itemtemplate 复选框 服务器 | 更新日期: 2023-09-27 17:50:35

我得到错误"服务器标记格式不佳。"

在这部分代码的复选框上

<ItemTemplate>
   <table style="table-layout:fixed;" border="0" width="100%" cellpadding="0" cellspacing="0">
      <td class="ListItem" style="padding-left:0px">
        <asp:CheckBox ID="chkbox" runat="server" Checked='<%# DataBinder.Eval(Container,"Attributes['checked']") %>' ></asp:CheckBox>
      </td>
   </table>
</ItemTemplate>

我猜这是由于引号内的双引号包含单引号…我尝试了很多东西,比如用双引号替换数组中的单引号,甚至尝试通过索引访问属性,保护引号……No success

我看过很多关于这个错误的帖子,但是没有一个有帮助。有什么问题吗?

服务器标记在复选框和itemtemplate上没有很好地形成

查看使用内联语法

改变
  Checked='<%# DataBinder.Eval(Container,"Attributes['checked']") %>'

  Checked='<%# DataBinder.Eval(Container,"YourBoolPropName") %>'