TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Kishore
NA
65
8.9k
PIVOT the data and display in MVC view
Apr 15 2020 9:58 AM
I am trying to display the data in Pivot in MVC view. How to pivot the data by date wise and display the results with header and the values against each result. After getting the data from Procedure I am grouping by Heading and framing the model as follows. My model is as below
public
class
ResultModel
{
public
string
ResultName {
get
;
set
; }
public
int
ResultId {
get
;
set
; }
public
double
? Score {
get
;
set
; }
public
string
ResultDate {
get
;
set
; }
}
public
class
ResultGroupViewModel
{
public
string
Heading {
get
;
set
; }
public
List<ResultModel> ResultModel {
get
;
set
; }
}
public
List<ResultGroupViewModel> GetData()
{
List<ResultGroupViewModel> resultGroupViewModel =
new
List<ResultGroupViewModel>();
for
(
int
i = 1; i <= 5; i++)
{
ResultGroupViewModel resultViewModel =
new
ResultGroupViewModel();
resultViewModel.Heading =
"Heading"
+ i.ToString();
resultViewModel.ResultModel =
new
List<ResultModel>();
for
(
int
j = 1; j <= 5; j++)
{
resultViewModel.ResultModel.Add(
new
ResultModel()
{
ResultId = j,
ResultName =
"ResultName"
+ j,
Score =
double
.Parse(j.ToString()),
ResultDate =
string
.Format(
"{0:MM/dd/yy}"
, DateTime.Now.AddDays(
double
.Parse(j.ToString())))
}); ;
}
resultGroupViewModel.Add(resultViewModel);
}
return
resultGroupViewModel;
}
}
I am trying to display the result in view as follows
https://i.stack.imgur.com/rgXEU.png
Reply
Answers (
1
)
How to show pdf in asp.net webforms
Passing data from one view to another