For smart Primates & ROBOTS (oh and ALIENS ).

Blogroll

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

Multiple attribute passing in querySelectorAll

Multiple attribute passing in querySelectorAll     Here I am demonstrating code to how to pass multiple attributes in querySelectorAll. <...

Ads Inside Post

Powered by Blogger.

Arsip