students totalpoints newassignemnt testing assignment
raj kumar 30/55 10/20 10/15 10/20
but it displays like this
students totalpoints newassignemnt students totalpoints testing students totalpoints assignment
raj kumar 30/55 10/20 raj kumar 30/55 10/15 raj kumar 30/55 10/20
raj kumar 30/55 10/20 raj kumar 30/55 10/15 raj kumar 30/55 10/20
raj kumar 30/55 10/20 raj kumar 30/55 10/15 raj kumar 30/55 10/20
3 assignments there so it displays 3 rows. but i need to display in a single row.
@{
List cols = new List();
foreach (GradeBook.StudentGradeBook x in Model.Student)
{
cols.Add(grid.Column(format:@@item.FirstName @item.lastName , header: "student"));
cols.Add(grid.Column(format:@@totptsawd/@totptspbl , header: "Total Points"));
cols.Add(grid.Column(format:@@item.PointsAwarded/@item.PointsPossible , header: x.AssignmentName));
}
}
Iftikar HussainPosted Jul 16, 2013, 8:18 AM
Regards,
Iftikar
vidhyaPosted Jul 16, 2013, 8:06 AM
Iftikar HussainPosted Jul 16, 2013, 7:50 AM
http://weblogs.asp.net/scottgu/archive/2007/05/19/using-linq-to-sql-part-1.aspx
Regards,
Iftikar
Jignesh TrivediPosted Jul 16, 2013, 7:44 AM
hi,
If you use Entity framework than please refer my article
http://www.c-sharpcorner.com/UploadFile/ff2f08/call-store-procedure-from-entity-framework/
vidhyaPosted Jul 16, 2013, 7:28 AM
Iftikar HussainPosted Jul 16, 2013, 7:14 AM
Regards,
Iftikar
vidhyaPosted Jul 16, 2013, 7:09 AM
SET @AssignmentList =STUFF((SELECT DISTINCT ',[' + assignmentname + ']' FROM assignment where coursesectionid='b78a6efe-ac77-4e49-806a-fc2fad71068b' FOR XML PATH('')),1,1,'')
SET @Sql ='select *
from
(
select p.firstname,p.lastname,a.assignmentname,a.pointspossible
from person2 p
inner join coursesectionroster cs
on cs.personid = p.personid
inner join assignment a
on a.coursesectionid = cs.coursesectionid
left join assignmentsubmission asg
on a.assignmentid=asg.assignmentid
where cs.coursesectionid=''b78a6efe-ac77-4e49-806a-fc2fad71068b''
and cs.courserole=2
)t
PIVOT(SUM(pointspossible) FOR assignmentname IN(' + @AssignmentList + '))p'
EXEC (@SQL)
Iftikar HussainPosted Jul 16, 2013, 7:07 AM
Regards,
Iftikar
vidhyaPosted Jul 16, 2013, 7:04 AM
Iftikar HussainPosted Jul 16, 2013, 2:04 AM
Before doing this in WebGrid, can you share me your table design? How you are storing the Student Mark info? I think you need to convert rows to column in your sql query. I believe you have fixed number of assignment.
Regards,
Iftikar