So the beginning of my View is
@foreach ( var G in ViewBag.GroupedBySec )
{
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<table class="table table-striped assessment-table">
<tbody>
<tr>
<td class="black-n-white" colspan="4">@G.Key</td>
</tr>
<tr>
<td>Section</td><td>Component</td><td>Completeness Level (0-100%)</td><td>Readines</td>
</tr>
@var GroupedBySubsection = G.GroupBy(x => x.SubsectionTitle);
@foreach ( var g in GroupedBySubsection )
{
@foreach ( var qa in g )
{
and I'm getting errors on the
@var GroupedBySubsection = G.GroupBy(x => x.SubsectionTitle);
@foreach ( var g in GroupedBySubsection )
lines which say
The name 'var' does not exist in the current context
and
The name 'GroupedBySection' does not exist in the current context
Any idea what I'm doing wrong?
Alternatively, any suggestions for how I can get a C# object that has the entire groupings and subgroupings so that I don't have to write all this crap in my View?
My Controller method for this page is like
[HttpGet]
public ActionResult Peek ( Guid pid )
{
ViewBag.PartnerId = pid;
List<AnswerInfo> AllAnswers = this._Db.GetAnswersByPartner(pid);
ViewBag.GroupedBySec = AllAnswers.GroupBy(A => A.SectionTitle);
return View();
}