Note that there are some explanatory texts on larger screens.

plurals
  1. POasp.net Sorting an inner ListView
    primarykey
    data
    text
    <p>I've only been using asp.net for about a month now so I hope my vernacular makes sense. I would much rather prefer to use MVC but this particular view page seemingly has to be using aspx and code-behind files as it needs to be "included" in a flat-file CMS.</p> <p>I have 3 nested ListViews. The first is populated (databound) from my code-behind file using LINQ and works great, gets a list of <em>years</em>. Then for the second ListView I call a function GetRecordsFromYear which gets all the <em>records</em>, again using LINQ in the code-behind.</p> <pre><code>&lt;asp:ListView ID="lv2" runat="server" DataSource='&lt;%# GetRecordsFromYear(Convert.ToInt32(Container.DataItem)) %&gt;'&gt; </code></pre> <p>Next, for each <em>Record</em> there is a navigation property (one-to-many relationship with another table) with <em>Degrees</em>. The <em>Degrees</em> table has a column named "gradyear" which is what I want to sort this last ListView by. I can output this fine by doing something like:</p> <pre><code>&lt;asp:ListView ID="lv3" runat="server" DataSource='&lt;%# Eval("Degrees") %&gt;'&gt; </code></pre> <p>Everything works perfectly except I can't figure out how to sort this final ListView. I can't use LINQ because I never really retrieved this data, it's a navigation property of the first table <em>Records</em>. I guess I could probably just use another function to retrieve the data but it seems silly to have to keep querying the database all the time when I have the navigation property available to me. I don't want a button to sort it, just have it sorted by default.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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.
 

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