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();
---------------------------------------------------------------------------------------------------
Use listed below code to achieve target:
---------------------------------------------------------------------------------------------------
string m = "Total Marks =" + dataGridView1.Rows.Cast<
---------------------------------------------------------------------------------------------------
0 comments:
Post a Comment