title: System.InvalidCastException: Unable to cast object of type 'System.Linq.GroupedEnumerable
body: <p>I am grouping some data together, so that I can display it on the front page (ASPX).</p>
  
  <p>I have the following code :-</p>
  
  <pre><code>IEnumerable&lt;ReportQuestion&gt; questionSubjectGrps =
      questionsBll.GetReportQuestions()
                  .Where(x =&gt; x.VersionId == iLatestVersion);
  
  reportQuestionsList =
      questionSubjectGrps.GroupBy(q =&gt; q.SubjectId,
                                  (qid, qs) =&gt; qs.GroupBy(q =&gt; q.ParentId));
  
  foreach (ReportQuestion reportQuestion in reportQuestionsList)
  {
      ReportQuestionsGuiDisplay reportQuestionsGuiDisplay = 
          new ReportQuestionsGuiDisplay();
  
      reportQuestionsGuiDisplay.ParentQuestionTitle = 
          questionsBll.GetQuestionParents()
                      .FirstOrDefault(
                           x =&gt; x.QuestionParentId == reportQuestion.ParentId)
                      .QuestionParentTitle;
  
      reportQuestionsGuiDisplay.ReportId = reportQuestion.ReportId;
  
      reportQuestionsGuiDisplayList.Add(reportQuestionsGuiDisplay);
  }
  </code></pre>
  
  <p>On the front end (ASPX), I have the following :</p>
  
  <pre><code>&lt;% foreach (ReportQuestionsGuiDisplay report in reportQuestionsGuiDisplayList)
  {%&gt;
      &lt;div class="hrLightBlue"&gt;&lt;/div&gt;
      &lt;div class="RPTContentTitle2"&gt;
        &lt;%= report.SubjectTitle %&gt;
      &lt;/div&gt;
      &lt;div class="hrLightBlue"&gt;&lt;/div&gt;
  &lt;%} %&gt;
  </code></pre>
  
  <p>However I am getting the following error :</p>
  
  <blockquote>
    <p>Unable to cast object of type
    '<code>System.Linq.GroupedEnumerable``3[SCPerformance.Shared.Models.ReportQuestion,System.Nullable``1[System.Int32],SCPerformance.Shared.Models.ReportQuestion]</code>'
     to type '<code>SCPerformance.Shared.Models.ReportQuestion</code>'.</p>
  </blockquote>