Note that there are some explanatory texts on larger screens.

plurals
  1. POFormat linq query output for a grid
    primarykey
    data
    text
    <p>I want to format results form my linq query and pass it to a grid. I have Weeks first date(Date on Monday) as my input with which I pull data for that week(Monday through Sunday.</p> <p>Here is what I have stored in DB, which is being pulled via linq query:</p> <pre><code> Date Hours 07/29/2013 1.3 07/29/2013 2.0 07/30/2013 3.1 07/31/2013 0.1 07/31/2013 5.2 08/01/2013 1.1 08/01/2013 1.1 08/01/2013 2.2 08/02/2013 3.3 08/02/2013 4.0 08/03/2013 2.1 </code></pre> <p>Here is how I want to display the output in grid:</p> <pre><code> Day Hours Monday 2.3 Tuesday 3.1 Wednesday 5.3 Thursday 4.4 Friday 9.5 Saturday 2.1 Sunday 0.0 </code></pre> <p>Controller Action:</p> <pre><code>[HttpPost] [GridAction] public ActionResult GridOutput(string dateOnMonday) { DateTime DateOnMonday = Convert.ToDateTime(dateOnMonday); var WeeklyHoursToGrid = (from h in db.vwHours.Where(h.Date &gt;= DateOnMonday &amp;&amp; h.Date &lt; DateOnMonday.AddDays(7)) select h.Hours).Sum(); return View(new GridModel { Data = WeeklyHoursToGrid }); } </code></pre> <p>HTML(Grid):</p> <pre><code>&lt;%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl&lt;IEnumerable&lt;UI.Models.vwHour&gt;&gt;" %&gt; &lt;div&gt; &lt;% Html.GridFor("WeekDetails", "GridOutput", "Hours", GridOptions.EnableSelecting, Model).Columns(column =&gt; { column.Bound(o =&gt; o.Date).Title("Day");//Display Day's instead of Date column.Bound(o =&gt; o.Hours).Title("Hours");//Display Total Hours for that day }).Render(); %&gt; &lt;/div&gt; </code></pre> <p>Any help is much appreciated</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