Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将内部中继器绑定到分组列表的分组列表时出现问题_C#_List_Datasource_Repeater - Fatal编程技术网

C# 将内部中继器绑定到分组列表的分组列表时出现问题

C# 将内部中继器绑定到分组列表的分组列表时出现问题,c#,list,datasource,repeater,C#,List,Datasource,Repeater,我的目标如下: var years = articles.GroupBy(a => a.Year).Select(yearGroup => new { Year = yearGroup.Key, PerMonth = yearGroup.GroupBy(a => a.Month).Select(monthGroup => new { Month = monthGroup.Key, Articles = monthGr

我的目标如下:

var years = articles.GroupBy(a => a.Year).Select(yearGroup => new
{
    Year = yearGroup.Key,
    PerMonth = yearGroup.GroupBy(a => a.Month).Select(monthGroup => new
    {
        Month = monthGroup.Key,
        Articles = monthGroup.ToList()
    }).ToList()
}).ToList();

Repeater1.DataSource = years;
Repeater1.DataBind();
我尝试如下所示来显示:

<asp:Repeater ID="Repeater1" runat="server">
    <ItemTemplate>
        <div class="yearGroup">
            <h1 class="yearHeading"><%# DataBinder.Eval(Container.DataItem, "Year") %></h1>
            <asp:Repeater ID="Repeater2" runat="server" DataSource='<%# DataBinder.Eval(Container.DataItem, "PerMonth")%>'>
                <ItemTemplate>
                    <div class="monthGroup">
                        <h3 class="monthHeading"><%# DataBinder.Eval(Container.DataItem, "Month") %></h3>
                        <asp:Repeater ID="Repeater3" runat="server" DataSource="<%# DataBinder.Eval(Container.DataItem, "Articles") %>">
                            <ItemTemplate>
                                <h1>Article title</h1>
                                <%--<div class="Article">
                                    <%# DataBinder.Eval(Container.DataItem, "Title") %>
                                </div>--%>
                            </ItemTemplate>
                        </asp:Repeater>
                    </div>
                </ItemTemplate>
            </asp:Repeater>
        </div>
    </ItemTemplate>
</asp:Repeater>
我的事件查看器说

服务器标记的格式不正确


请尝试将服务器标记周围的标记替换为“”

以便:

"<%# DataBinder.Eval(Container.DataItem, "Articles") %>"
变成:

'<%# DataBinder.Eval(Container.DataItem, "Articles") %>'
'<%# DataBinder.Eval(Container.DataItem, "Articles") %>'