ListView数据分组

时间:2016-02-17 06:52:52

标签: listview

有人可以帮我解决ListView问题。我有2个表,dbo.category和dbo.files他们有外键,它是categoryID。我希望显示类似DesiredResult

的内容

到目前为止,我获得的是CurrentResult我想仅将类别显示为标题,然后文件将列在标题下方

这是我到目前为止所做的事情

    <asp:ListView ID="ListView1" runat="server"
        DataSourceID="SqlDataSource1" GroupPlaceholderID="groupPlaceholder1" ItemPlaceholderID="itemPlaceholder1">
        <LayoutTemplate>
            <div>
                <div id="groupPlaceholder1" runat="server">
                </div>
            </div>
        </LayoutTemplate>
        <GroupTemplate>
            <div style="clear:both">
                <div id="itemPlaceholder1" runat="server">
                </div>
            </div>
        </GroupTemplate>
        <ItemTemplate>
            <div style="float:left">
                <asp:Label ID="lbCategory_Name" runat="server" Text='<%#Eval("Category_Name") %>' />
                <ul><asp:LinkButton ID="lkPolicy_Title" runat="server" Text='<%#Eval("Policy_Title") %>' /></ul><br />
            </div>
        </ItemTemplate>
        <GroupSeparatorTemplate>
            <div runat="server">
                <div style="clear:both"></div>
            </div>
        </GroupSeparatorTemplate>
    </asp:ListView>
    <br />
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
     ConnectionString="<%$ ConnectionStrings:ItPolicyConnectionString %>"
     SelectCommand="SELECT c.Category_Name, Policy_Title FROM Files f Inner join Category c on f.CategoryID = c.CategoryID Order by c.Category_Name"></asp:SqlDataSource>

0 个答案:

没有答案