table as data as below
Id Std Div Count Cvalue
1 one A 50 Nos
2 one B 30 Nos
3 one C 40 Nos
4 one D 24 Nos
5 Two A 32 Nos
6 Two B 54 Nos
7 Two C 33 Nos
8 Two D 45 Nos
9 Three A 32 Nos
6 Three B 54 Nos
7 Three C 33 Nos
8 Three D 45 Nos
and so on ...
- DECLARE @Test AS TABLE(Id INT,Std CHAR(10),Div CHAR(10),[Count] INT,Cvalue CHAR(10))
- INSERT INTO @Test VALUES(1,'one','A',50,'Nos')
- INSERT INTO @Test VALUES(2,'one','B',30,'Nos')
- INSERT INTO @Test VALUES(3,'one','C',40,'Nos')
- INSERT INTO @Test VALUES(4,'one','D',24,'Nos')
- INSERT INTO @Test VALUES(5,'Two','A',32,'Nos')
- INSERT INTO @Test VALUES(6,'Two','B',54,'Nos')
- INSERT INTO @Test VALUES(7,'Two','C',33,'Nos')
- INSERT INTO @Test VALUES(8,'Two','D',45,'Nos')
- INSERT INTO @Test VALUES(9,'Three','A',32,'Nos')
- INSERT INTO @Test VALUES(10,'Three','B',54,'Nos')
- INSERT INTO @Test VALUES(11,'Three','C',33,'Nos')
- INSERT INTO @Test VALUES(12,'Three','D',45,'Nos')
I need to display data in view from database in matrix form as
i am not getting result with the below query
- var model = (from p in db.std
- group p by p.Std into g
- select new DataViewModel
- {
- rowKey = g.Key,
- rowData = g.Select(s => new P1DataViewModel {Div= s.Div ,count= s.Count }).ToList()
- }).ToList();
- return View(model);