c# - How to perform sum of all cells in a column in grid using linq -


i have requirement. like....

sname marks percentage  aa    50     50 aa    60     60 bb    80     80 bb    60     60 

here want add marks , display percentage below

sname marks percentage aa    50     50 aa    60     60 ----------------- aa    110    55 ---------------- bb    80     80 bb    60     60 ----------------- bb    140    70 ----------------- 

it should done using linq query using follwing linq query performs grouping display.

list<studentsmarkslist> mrksbrpby = (from n in lstmrks      group n new { n.studentname,n.total,n.percentage }           g  orderby g.key.studentname      select new studentsmarkslist      {          studentname = g.key.studentname,          total = g.key.total,          percentage = g.key.percentage      }).tolist(); return mrksbrpby 

please suggest me how perform sum , percentage mentioned above way using linq query

you want use .sum() method summing marks values, , .average() getting average percentage.

examples of usage can found following msdn links:

.sum() read more here: http://msdn.microsoft.com/en-us/library/bb338442.aspx

.average() read more here: http://msdn.microsoft.com/en-us/library/bb338413.aspx


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -