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

How to make center align child div

 How to make center align child div?   Suppose you have 2 Div tag. And want the make inner tag center <div id="d1">      ...

Ads Inside Post

Powered by Blogger.

Arsip