Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The ASP.NET content that you have should be put in a <code>Repeater</code>. The <code>files</code> that you have should then be grouped by the month and date. So basically you will end up with a parent-child list. The parent which is the group of files will be bound to the <code>Repeater</code>, and the children which are the files belonging to that group will be bound the the <code>GridView</code> in the <code>Repeater</code>.</p> <p><br/></p> <h2>The ASP.NET content</h2> <p>The ASP.NET content would be something along this line. Take note the <code>gvInvoiceList</code> <code>DataSource</code> property is bound to <code>InvoiceList</code>, a property of the group that I came up with (which you will see in the code below) that will have a list of files belonging to the group.</p> <pre><code>&lt;asp:Repeater ID="repInvoiceGroups" runat="server"&gt; &lt;ItemTemplate&gt; &lt;table width="40%" border="0" style="margin-left:auto; margin-right:auto;"&gt; &lt;tr&gt;&lt;td&gt;&lt;asp:Label ID="lblGridHeader" CssClass="TextFont" Text='&lt;%# Eval("MonthYear", "{0:MMMM yyyy}") %&gt;' runat="server"&gt;&lt;/asp:Label&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td align="center"&gt; &lt;asp:GridView ID="gvInvoiceList" runat="server" AutoGenerateColumns="false" AllowSorting="true" DataSource='&lt;%# Eval("InvoiceList") %&gt;'&gt; &lt;columns&gt; &lt;asp:TemplateField ItemStyle-Width="10%" HeaderText="File Type"&gt; &lt;ItemTemplate&gt;&lt;asp:HyperLink ID="imgFileType" ImageUrl="images/Icon_Pdf.gif" NavigateUrl='&lt;%# SetNavigateUrl(Eval("Name")) %&gt;' runat="server"&gt;&lt;/asp:HyperLink&gt;&lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;asp:boundfield datafield="Name" headertext="Invoice #"/&gt; &lt;asp:boundfield datafield="LastWriteTime" headertext="Date Modified"/&gt; &lt;/columns&gt; &lt;/asp:GridView&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/ItemTemplate&gt; &lt;/asp:Repeater&gt; </code></pre> <p><br/></p> <h2>The code-behind</h2> <p>As for the code, I'm not fluent on using <code>DataTable</code> to have the parent-child relationship needed for the ASP.NET structure that I used for my answer, but it should be easily doable using normal classes. And I'm also not fluent on using VB.NET, so excuse my example which will be using C#, which I guess you should able to convert it quite easily to VB.NET.</p> <p>I'm using <code>Linq</code> to do the grouping and an anonymous class to have the parent-child relationship for this, so the code is rather short.</p> <pre><code>repInvoiceGroups.DataSource = files .GroupBy(f =&gt; f.LastWriteTime.ToString("yyyy-MM")) .Select(g =&gt; new { MonthYear = DateTime.ParseExact(g.Key, "yyyy-MM", CultureInfo.InvariantCulture), InvoiceList = g.OrderByDescending(f =&gt; f.LastWriteTime) }) .OrderByDescending(o =&gt; o.MonthYear); repInvoiceGroups.DataBind(); </code></pre> <p><br/> p/s: The code was written in a text editor and untested. Let me know if you face any errors. :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload