Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to create category and list in one query with Linq
    primarykey
    data
    text
    <p>I want to create something like this using a <code>DataList</code> and Flow markup:</p> <pre><code>|-----------------------| | Title | |-----------------------| | [x] Title | | [x] Title | | ... | ------------------------- </code></pre> <p>I have a table (modeled in Linq2Sql) <code>Foo</code> that has these fields</p> <pre><code>int id; int? parentId; string title; Foo Parent; EntitySet&lt;Foo&gt; Children; </code></pre> <p>Now, when there is a null parent, it means it's a top level category, and if the parent has a value, it's part of the category list.</p> <p>I have created a <code>DataList</code>, and used a <code>LinqDataSource</code> with a query that looks like this:</p> <pre><code>&lt;asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="MyNameSpace.FooDataContext" Select="new (Title, Children)" TableName="Foo" Where="ParentID = NULL"&gt; &lt;/asp:LinqDataSource&gt; &lt;asp:DataList ID="FooList" runat="server" DataSourceID="LinqDataSource1" BorderColor="Black" BorderWidth="1px" RepeatLayout="Flow"&gt; &lt;ItemTemplate&gt; &lt;asp:Label ID="TitleLabel" runat="server" Text='&lt;%# Eval("Title") %&gt;' /&gt; &lt;br /&gt; &lt;asp:Repeater ID="Repeater1" runat="server" DataSourceID="&lt;%# Eval("Children") %&gt;"&gt; &lt;ItemTemplate&gt; &lt;asp:CheckBox ID="Checks" Text="&lt;%# Eval("Title") %&gt;" runat="server" /&gt; &lt;/ItemTemplate&gt; &lt;/asp:Repeater&gt; &lt;/ItemTemplate&gt; &lt;/asp:DataList&gt; </code></pre> <p>This obviously doesn't work. <strong>How can I utilize the Children collection in a repeater of a DataList item?</strong></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.
 

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