skip to main
|
skip to sidebar
My .Net World
Sunday, November 1, 2009
DataGridView - Sum of a Column using LINQ - Windows Forms
You can use this one liner using LINQ instead of looping throw DataGridView Rows.
DataView view = adventureWorksDataSet.Tables[0].DefaultView ;
// view.RowFilter = "Included = true";
// LINQ Sum: 152.1
decimal total = view.Cast
().Sum(row => (Int32)row["EmployeeID"]);
// LINQ count: 2 (to prove we have exluded the one row)
int count = view.Cast
().Count();
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
Links
dimecasts
polymorphicpodcast
imar.spaanjaars
matt berserth
Followers
Blog Archive
►
2011
(2)
►
April
(1)
►
February
(1)
►
2010
(11)
►
October
(1)
►
September
(2)
►
July
(1)
►
June
(4)
►
May
(1)
►
March
(1)
►
January
(1)
▼
2009
(9)
▼
November
(5)
jQuery datepicker control on ASP.NET (controls).
JQuery videos
setting app.config for different environments
DataGridView - Sum of a Column using LINQ - Window...
C# - Converting DataGridView to DataSet - Windows ...
►
October
(1)
►
August
(1)
►
July
(2)
About Me
Prahlad
View my complete profile
No comments:
Post a Comment