如何在listview中对layouttemplate进行分组

时间:2014-10-24 06:04:12

标签: asp.net listview

我知道将物品分组的方法。但如何将每个8个数据绑定项目的布局模板分组?

这是代码

<ul class="slides">
                <asp:ListView runat="server" ID="MyListView" OnItemDataBound="MyListView_ItemDataBound" GroupItemCount="2" >
                    <LayoutTemplate>
                        <li>
                            <asp:PlaceHolder runat="server" ID="groupPlaceHolder" />
                        </li>
                    </LayoutTemplate>
                    <GroupTemplate>
                        <div class="gourptpl">
                            <asp:PlaceHolder runat="server"  ID="itemPlaceHolder"/>
                        </div>
                    </GroupTemplate>
                    <GroupSeparatorTemplate>
                        <div class="sper"></div>
                    </GroupSeparatorTemplate>  
                    <ItemTemplate>
                        <%-- The item template is used to render each of the rows of the DataTable that has been binded to the ListView control. --%>
                        <div class="ft-item">
                            <span class="ft-image">
                                <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">
                                    <asp:Label runat="server" ID="ButtonText" />
                                    <asp:Image ID="Image1" runat="server" />
                                </asp:LinkButton>
                            </span>
                        </div>
                    </ItemTemplate>
                </asp:ListView>
                 </ul>

我想要的只是重复GroupTemplate每2个项目和LayoutTemplate每个8个项目。 谢谢。

1 个答案:

答案 0 :(得分:0)

我帮助自己。在上面的listview的datatemplate中嵌套另一个listview。实际上我想自定义listview类,但不知道如何。