【问题标题】:Can I create a ListView with dynamic GroupItemCount?我可以使用动态 GroupItemCount 创建 ListView 吗?
【发布时间】:2010-09-05 23:22:39
【问题描述】:

我正在使用新的 ASP.Net ListView 控件来列出数据库项目,这些项目将根据它们的列之一按部分分组在一起,如下所示:

region1
    store1
    store2
    store3
region2
    store4
region3
    store5
    store6

这可能与 ListView 的 GroupItemTemplate 相关吗?我看到的每个示例都使用每个组的静态项目数,这对我不起作用。我是否误解了 GroupItem 的用途?

【问题讨论】:

    标签: asp.net .net-3.5 listview


    【解决方案1】:

    我没有使用 GroupItemCount,但我采用了这个由 Matt Berseth 编写的标题为 Building a Grouping Grid with the ASP.NET 3.5 LinqDataSource and ListView Controls 的示例,并按照您的需要按键对项目进行分组。

    它涉及使用外部和内部 ListView 控件。效果很好,试试看。

    【讨论】:

    • 我希望 ListView 可以在不嵌套另一个控件的情况下做到这一点,但如果不是这样,我会这样做。只是试图保持设计简单。
    【解决方案2】:

    确保您正在执行 DataBind AFTER 设置 GroupItemCount 属性。我遇到了同样的问题,这就是我为解决它所做的。

    【讨论】:

      【解决方案3】:

      我尝试以编程方式使用 GroupItemCount,但它没有给我预期的结果。

      我按照 Otto 的建议,实现了一个外部和内部的 ListView 控件。这似乎是最好的解决方案。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-09-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-08-23
        相关资源
        最近更新 更多