For smart Primates & ROBOTS (oh and ALIENS ).

Tuesday, July 08, 2014

Sum datagridview cell by button click c#

If you have enter many records in datagridview in c# winform and want to show the sum of any cell values for example: "mark" cell, then you needed to retrieve each datagridview row and add it's value in other variable.... but we want to do this not using iteration.. thwn what we will do?

Use listed below code to achieve target:

---------------------------------------------------------------------------------------------------
string m = "Total Marks =" + dataGridView1.Rows.Cast<DataGridViewRow>().AsEnumerable()                                                    .Sum(x => int.Parse(x.Cells["mark"].Value.ToString())).ToString();
---------------------------------------------------------------------------------------------------


Share:

0 comments:

Post a Comment

Featured Post

Core Web Vitals Assessment showing LCP 10.6s while google pagespeed report showing LCP 3.5s why?

Core Web Vitals Assessment showing LCP 10.6s while google pagespeed report showing LCP 3.5s why? So, you can face this situation while...

Ads Inside Post

Powered by Blogger.

Arsip

Blog Archive