Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you have the appropriate relationships set up in the database (and therefore, in the DBML), you may want to consider something like this (UNTESTED):</p> <pre><code>&lt;table&gt; &lt;tr&gt; &lt;asp:Repeater ID="_users" runat="server"&gt; &lt;ItemTemplate&gt; &lt;td&gt;&lt;%# Eval("UserName") %&gt;&lt;/td&gt; &lt;/ItemTemplate&gt; &lt;/asp:Repeater&gt; &lt;/tr&gt; &lt;asp:Repeater ID="_products" runat="server"&gt; &lt;ItemTemplate&gt; &lt;tr&gt; &lt;td&gt;&lt;%# Eval("Product.ProductName") %&gt;&lt;/td&gt; &lt;asp:Repeater ID="_users" runat="server" DataSource='&lt;%# GetUsersProducts(Eval("ProductID")) %&gt;'&gt; &lt;ItemTemplate&gt; &lt;td&gt;&lt;%# Eval("count") %&gt;&lt;/td&gt; &lt;/ItemTemplate&gt; &lt;/asp:Repeater&gt; &lt;/ItemTemplate&gt; &lt;/asp:Repeater&gt; &lt;/table&gt; </code></pre> <p>Code-behind:</p> <pre><code>protected void Page_Load(object sender, EventArgs e) { _users.DataSource = context.Users.OrderBy(u =&gt; u.UserName); _users.DataBind(); _products.DataSource = context.Products; _products.DataBind(); } protected object GetUsersProducts(string ProductID) { var prodord = from op in context.OrderProducts where op.ProductID == ProductID select op; return from u in context.Users.OrderBy(u2 =&gt; u2.UserName) select new { count = prodord.Where(op =&gt; op.Order.User.UserID == u.UserID).Sum(op =&gt; op.ProductQty) }; } </code></pre> <p>You will obviously want to change around your markup and some of the object types, but I'm hoping this will get you going. I try to use the autogenerated class object structure as much as possible to avoid creating unreadable LINQ queries.</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