ASP.Net repeater header for the group (i.e. Month)

I have a data source that contains dated items for each row. They will be tied to the repeater and ordered by date. I would like to present each month as a separate table during visualization, but is there a way to do this using a repeater control without the need to dynamically add multiple repeaters from the server-side code?

Ideally, I would like to:

Examples Data:

Row 1: Title 1, 01/12/2009
Row 2: Title 1, 02/12/2009
Row 1: Title 1, 01/01/2010
Row 1: Title 1, 02/01/2009

Required output:

Dec 09
-------------------------------
Title  |  Date                 |
-------------------------------|
Title1 |  01/12/2009           |
-------------------------------|
Title2 |  02/12/2010           |
-------------------------------|

Jan 10
-------------------------------
Title  |  Date                 |
-------------------------------|
Title1 |  01/01/2010           |
-------------------------------|
Title2 |  02/01/2010           |
-------------------------------|
+3
source share
2 answers

PlaceHolder ItemTemplate, . PlaceHolders OnItemDataBound OnItemCreated . :

<ItemTemplate>

<asp:PlaceHolder id="table_end" visible="<%# _newMonthStarting && (!_firstMonth) %>" runat="server">
  </table>
</asp:PlaceHolder>

<asp:PlaceHolder id="table_end" visible="<%# _newMonthStarting %>" runat="server">
  <div><%# _monthHeader</div>
  <table>
    <tr>
      <th>Title</th>      
      <th>Date</th>      
    </tr>
</asp:PlaceHolder>
  <tr>
    <td><!-- data --></td>
    <td><!-- data --></td>
  </tr>
</ItemTemplate>

<FooterTemplate>
   </table>
</FooterTemplate>
+5

, , , .

, 1 , "Dec 09" "Jan 10". , , "OnDataBound" .

, .

+2

Source: https://habr.com/ru/post/1724116/


All Articles