【问题标题】:Nested repeater yields "malformed server tag"?嵌套中继器产生“格式错误的服务器标签”?
【发布时间】:2011-06-02 22:14:34
【问题描述】:

我正在尝试按照here 的描述做一个嵌套中继器,但它出错了。

我的中继器如下:

<asp:Repeater ID="HouseholdRepeater" runat="server">
    <ItemTemplate>
        <div><b><%# DataBinder.Eval(Container.DataItem,"Name") %></b></div>
        <div>
        <asp:Repeater ID="ApplicationRepeater" runat="server" DataSource="<%#((DataRowView)Container.DataItem).Row.GetChildrows("Applications") %>"> <!-- error here -->
            <ItemTemplate>
            <div>
                <a href="<%# DataBinder.Eval(Container.DataItem,"Link") %>"><%# DataBinder.Eval(Container.DataItem,"Description") %></a>
            </div>
            </ItemTemplate>
        </asp:Repeater>
        </div>
    </ItemTemplate>
</asp:Repeater>

我收到的错误消息是“服务器标签格式不正确”。

在我看来,它和这个例子一模一样。我没有看到它有什么问题。任何想法如何使这项工作?

另外,我使用来自 Linq 查询的匿名对象在代码中对其进行数据绑定。

【问题讨论】:

    标签: c# asp.net data-binding repeater


    【解决方案1】:

    您正在使用双引号来指定您的 DataSource 属性,但您的 DataSource 本身包含双引号。尝试用单引号将 DataSource 括起来:

    DataSource='<%#((DataRowView)Container.DataItem).Row.GetChildrows("Applications") %>'
    

    【讨论】:

      【解决方案2】:

      改变

      Row.GetChildrows("Applications")

      Row.GetChildrows(""Applications"")


      也改变

      &lt;a href="&lt;%# DataBinder.Eval(Container.DataItem,"Link")

      &lt;a href="&lt;%# DataBinder.Eval(Container.DataItem,""Link"")

      【讨论】:

        【解决方案3】:

        DataSource 部分看起来不正确...... DataSource 应该是这样的

        ''

        【讨论】:

          【解决方案4】:

          改变

          DataSource="<%#((DataRowView)Container.DataItem).Row.GetChildrows("Applications") %>"
          

          DataSource='<%#((DataRowView)Container.DataItem).Row.GetChildrows("Applications") %>'
          

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2013-02-23
            • 2014-05-18
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多