This is a migrated thread and some comments may be shown as answers.

Grouping in RadListView Keeps Giving

1 Answer 122 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Mansoor
Top achievements
Rank 1
Mansoor asked on 07 Dec 2016, 05:48 AM

Hi,

I have a site where I display a list of available Camps that the users can register for.  What I would like to do is group them by "CampStartDate".  I have the code below but no matter how I try to group, I always get the error "The RadListView control does not have an item placeholder specified."

 

<telerik:RadListView ID="RadListView1" ItemPlaceholderID="DataGroupPlaceHolder2" DataGroups="CampStartDate" GroupPlaceholderID="DataGroupPlaceHolder1" runat="server" DataKeyNames="CampId" Skin="Bootstrap" OnSelectedIndexChanged="RadListView1_SelectedIndexChanged">
                <LayoutTemplate>
                    <asp:Panel ID="CampHolder" runat="server">
                    </asp:Panel>
                </LayoutTemplate>
                <GroupTemplate>
                     <div class="vc_row wpb_row vc_inner vc_row-fluid">
                        <asp:PlaceHolder ID="CampsHolder" runat="server"></asp:PlaceHolder>
                    </div>
                </GroupTemplate>
                <ItemTemplate>
                        <div class="rlvI vc_col-sm-4 wpb_column vc_column_container ">
                        <asp:Label ID="CampNameLabel" CssClass="camptitle" runat="server" Text='<%# "Camp: " + Eval("CampName") %>' />
                        <br /><br />
                        <strong>Start Date:</strong> <asp:Label ID="CampStartDateLabel" runat="server" Text='<%# Eval("CampStartDate", "{0:D}") %>' />
                    </div>
                </ItemTemplate>
                <AlternatingItemTemplate>
                    <div class="rlvA vc_col-sm-4 wpb_column vc_column_container ">
                        <asp:Label ID="CampNameLabel" CssClass="camptitle" runat="server" Text='<%# "Camp: " + Eval("CampName") %>' />
                        <br /><br />
                        <strong>Start Date:</strong> <asp:Label ID="CampStartDateLabel" runat="server" Text='<%# Eval("CampStartDate", "{0:D}") %>' />
                    </div>
                </AlternatingItemTemplate>
                <EmptyDataTemplate>
                    <div class="RadListView RadListView_Bootstrap">
                        <div class="rlvEmpty">
                            There are no camps to be displayed.</div>

                    </div>
                </EmptyDataTemplate>
                <ValidationSettings EnableModelValidation="False" EnableValidation="False" />
                   <DataGroups>
                     <telerik:ListViewDataGroup GroupField="CampStartDate" DataGroupPlaceholderID="DataGroupPlaceHolder1"
                         SortOrder="Ascending">
                         <DataGroupTemplate>
                             <asp:Panel runat="server" ID="Panel4" GroupingText='<%# (Container as RadListViewDataGroupItem).DataGroupKey %>'>
                                 <asp:PlaceHolder runat="server" ID="DataGroupPlaceHolder2"></asp:PlaceHolder>
                             </asp:Panel>
                         </DataGroupTemplate>
                     </telerik:ListViewDataGroup>
                 </DataGroups>
            </telerik:RadListView>

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 09 Dec 2016, 03:50 PM
Hi Mansoor,

The error is thrown due to the missing placeholder in the LayoutTemplate and the GroupTemplate:
<LayoutTemplate>
                   <asp:Panel ID="DataGroupPlaceHolder1" runat="server"></asp:Panel>

<telerik:RadListView ID="RadListView1" ItemPlaceholderID="DataGroupPlaceHolder2" DataGroups="CampStartDate"
    GroupPlaceholderID="DataGroupPlaceHolder1" runat="server" DataKeyNames="CampId" Skin="Bootstrap" OnNeedDataSource="RadListView1_NeedDataSource">
    <LayoutTemplate>
        <asp:Panel ID="DataGroupPlaceHolder1" runat="server"></asp:Panel>
        <asp:Panel ID="CampsHolder" runat="server">
        </asp:Panel>
   </LayoutTemplate>
    <ItemTemplate>
            <div class="rlvI vc_col-sm-4 wpb_column vc_column_container ">
            <asp:Label ID="CampNameLabel" CssClass="camptitle" runat="server" Text='<%# "Camp: " + Eval("CampName") %>' />
            <br /><br />
            <strong>Start Date:</strong> <asp:Label ID="CampStartDateLabel" runat="server" Text='<%# Eval("CampStartDate", "{0:D}") %>' />
        </div>
    </ItemTemplate>
    <AlternatingItemTemplate>
        <div class="rlvA vc_col-sm-4 wpb_column vc_column_container ">
            <asp:Label ID="CampNameLabel" CssClass="camptitle" runat="server" Text='<%# "Camp: " + Eval("CampName") %>' />
            <br /><br />
            <strong>Start Date:</strong> <asp:Label ID="CampStartDateLabel" runat="server" Text='<%# Eval("CampStartDate", "{0:D}") %>' />
        </div>
    </AlternatingItemTemplate>
    <EmptyDataTemplate>
        <div class="RadListView RadListView_Bootstrap">
            <div class="rlvEmpty">
                There are no camps to be displayed.</div>
        </div>
    </EmptyDataTemplate>
    <ValidationSettings EnableModelValidation="False" EnableValidation="False" />
       <DataGroups>
         <telerik:ListViewDataGroup GroupField="CampStartDate" DataGroupPlaceholderID="DataGroupPlaceHolder1"
             SortOrder="Ascending">
             <DataGroupTemplate>
                 <asp:Panel runat="server" ID="Panel4" GroupingText='<%# (Container as RadListViewDataGroupItem).DataGroupKey %>'>
                     <asp:PlaceHolder runat="server" ID="DataGroupPlaceHolder2"></asp:PlaceHolder>
                 </asp:Panel>
             </DataGroupTemplate>
         </telerik:ListViewDataGroup>
     </DataGroups>
</telerik:RadListView>

You can also refer to the following online demos for the grouping:
Hope this helps.


Regards,
Konstantin Dikov
Telerik by Progress
Telerik UI for ASP.NET AJAX is ready for Visual Studio 2017 RC! Learn more.
Tags
ListView
Asked by
Mansoor
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or