title: How to fill a WebGrid on the return of a Json Result in Asp.Net MVC3
body: <p>My application is in Asp.Net MVC3 with Razor View Engine coded in C#.Net. I want to populate a WebGrid in my Asp.Net MVC3 View.</p>
  
  <p>But my requirement is i want to show the WebGrid on the selection of some dropDowns.
  Below is my Json</p>
  
  <pre><code>[AcceptVerbs(HttpVerbs.Get)]
          public JsonResult getPendingInvoices(Int64 candID, DateTime InDate)
          {
              Int64 timeId;
              var getTimeSheetId= from k in db.TimeSheetInfoes
                               where k.PersonalInformationID == candID &amp;&amp; k.TimeSheetDate == InDate &amp;&amp; k.InvoicedFlag == false
                               select k.TimeSheetID;
  
              timeId = getTimeSheetId.Single();
  
              var getInvoice = (from K in db.TimeSheetTasks
                                where K.TimeSheetID == timeId
                                select new TimeSheetsTaskClass { TaskInfoId =(Int64)K.TimeSheetID, Task = K.Task, TaskDateDay = (DateTime)K.TaskDate, ProjectNameDay = K.ProjectName, Day=K.Day, TaskHours = (decimal)K.TaskHours, ApprovingManager = K.ApprovingManager, OTHours = (decimal)K.OTHours }).ToList();
  
              return Json(getInvoice, JsonRequestBehavior.AllowGet); 
          }
  </code></pre>
  
  <p>The Date and the Candidate Id is passed from my values selected.
  Below is my Jquery.</p>
  
  <pre><code> $("#MyDropdown").live("change", function () {
  
              $.getJSON("/../Invoice/getPendingInvoices", { candID: $("#ddlCandidateDispName").attr("value"), InDate: $("#dtpInvoiceDate").val() }, function (data) {
                  $.each(data, function (i, TimeSheetsTaskClass) {
  
                  });
                  grid = new WebGrid(Model);
              });
          }
      });
  </code></pre>
  
  <p>This is what i have tried.
  I want to fill my WebGrid with the Data in my TimeSheetsTaskClass.
  Below is my TimeSheetsTaskClass in my Controller</p>
  
  <pre><code>public class TimeSheetsTaskClass
          {
              public Int64 TaskInfoId { get; set; }
              public string Task { get; set; }
              public DateTime TaskDateDay { get; set; }
              public string ProjectNameDay { get; set; }
              public string Day { get; set; }
              public Decimal TaskHours { get; set; }
              public decimal OTHours { get; set; }
              public string ApprovingManager { get; set; }
          }
  </code></pre>
  
  <p>Below is how im using my class</p>
  
  <pre><code>@model IEnumerable&lt;RecruitmentPortal.Controllers.InvoiceController.TimeSheetsTaskClass&gt;
  </code></pre>
  
  <p>Below is how im Declaring WebGrid Variable.</p>
  
  <pre><code>var grid = new WebGrid(Model);
  </code></pre>
  
  <p>Below is how im showing my webGrid in my cshtml.</p>
  
  <pre><code>&lt;div id="grids"&gt;
  @grid.GetHtml()
  &lt;/div&gt;
  </code></pre>
  
  <p>Please guide how can i show the Data in my WebGrid.</p>