Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First of all, I think you are over-complicating the way you're doing the control. If you were to use LINQ or EF for your database access, you could do this with 2 nested repeaters and no complicated code behind. However, you can start by simplifying the query down to something like this:</p> <pre><code>SELECT * FROM tblperiods p CROSS JOIN tblrooms r LEFT JOIN tblbookings b ON p.period_id = b.period_id AND r.room_id = b.room_id AND b.booking_date = '2012-08-01' </code></pre> <p>This will get you enough information to produce the whole output in a single query for a given day. If you don't want to use EF or LINQ-to-SQL, you can still do a bit of LINQ magic to separate this out further by room, which you can then use for your databinding (forgive the C#, VB.NET is a bit rusty!):</p> <pre><code>DataTable dt = new DataTable(); dt.Fill(objDataReader); // Loads all data into the DataTable var groupedRows = dt.Rows.Cast&lt;DataRow&gt;().GroupBy(row =&gt; new { RoomId = (int) row["room_id"], RoomName = (string) row["room_name"] }); rpRows.DataSource = groupedRows; rpRows.DataBind(); </code></pre> <p>Then you would have Repeaters like so:</p> <pre><code>&lt;table&gt; &lt;thead&gt;&lt;tr&gt;&lt;th&gt;Rooms &amp;amp; Resources&lt;/th&gt; &lt;asp:Repeater runat="server" id="rpHeader"&gt; &lt;ItemTemplate&gt; &lt;td&gt;&lt;%# Eval("period_name") %&gt;&lt;/td&gt; &lt;/ItemTemplate&gt; &lt;/asp:Repeater&gt; &lt;/tr&gt;&lt;/thead&gt; &lt;asp:Repeater runat="server" id="rpRows"&gt; &lt;ItemTemplate&gt; &lt;tr&gt; &lt;th&gt;&lt;!-- Put room header stuff here --&gt;&lt;%# Eval("Key.RoomName") %&gt;&lt;/th&gt; &lt;asp:Repeater runat="server" DataSource="&lt;%# Container.DataItem %&gt;"&gt; &lt;ItemTemplate&gt; &lt;td&gt; &lt;!-- Per-booking info --&gt; &lt;asp:Label runat="server" Visible='&lt;%# Eval("booking_id") == DBNull.Value %&gt;'&gt;Not Booked&lt;/asp:label&gt; &lt;asp:Label runat="server" Visible='&lt;%# Eval("booking_id") != DBNull.Value %&gt;'&gt;Booked!&lt;/asp:label&gt; &lt;/td&gt; &lt;/ItemTemplate&gt; &lt;/asp:Repeater&gt; &lt;/tr&gt; &lt;/ItemTemplate&gt; &lt;/asp:Repeater&gt; &lt;/table&gt; </code></pre> <p>I've not given the code for databinding the header row, but this is simply a <code>select * from tbl_periods</code></p> <p>Note that none of this code was tested, and probably needs a little adjusting on the data binding.</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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