sir I am so sorry to send you the code for converting list to datatable as per your code.Actually the process is given bellow
1- cretate a model means a class as per the fields come from list
I modefy that in bellow
var data = db.GetProc1().ToList();
var d = (from f in data
group f by new { f.Planner, f.Vendor_Location, f.Bulk_Material }
into myGroup
where myGroup.Count() > 0
select new
{
planner = myGroup.Key.Planner,
location = myGroup.Key.Vendor_Location,
material = myGroup.Key.Bulk_Material,
subject = myGroup.GroupBy(f => f.Week).Select
(m => new { Sub = m.Key, Value = m.Sum(c => c.Value) })
}).ToList();
here create model class in your project model
1- right click on the model folder add a class like bellow
public class planning
{
public string planner { get; set; }
public string location { get; set;}
public string material { get; set;}
public decimal subject { get; set; }
}
public ActionResult PivotTableView()
{
var data = db.GetProc1().ToList();
var d = (from f in data
group f by new { f.Planner, f.Vendor_Location, f.Bulk_Material }
into myGroup
where myGroup.Count() > 0
select new
{
planner = myGroup.Key.Planner,
location = myGroup.Key.Vendor_Location,
material = myGroup.Key.Bulk_Material,
subject = myGroup.GroupBy(f => f.Week).Select
(m => new { Sub = m.Key, Value = m.Sum(c => c.Value) })
}).ToList();
return View(d);
}
Proces for view
1- Right click on the method PivotTableView
2- Click the add view option from the option list
3 = tick the check box create a strolnly-typed view
4-select the model that created above as a class from the the dropdown list
5- click add
then in the view page add on he top
<pre>@model IEnumerable<projectname.Models.classname>
in the for loop and table row display the data