Value from DataGridViewRow Getting Error in C#

NazHim 201 Reputation points

hello I am using C# I want to get Column Value from DataGridViewRow using Column Name foreach (DataGridViewRow row in studentsDataGridView.Rows) { MarksOne += Convert.ToDecimal(row.Cells["Stu_MarOne"].Value.ToString()); MarksTwo += Convert.ToDecimal(row.Cells["Stu_MarTwo"].Value.ToString()); MarksThree += Convert.ToDecimal(row.Cells["Stu_MarThre"].Value.ToString()); } Getting Error why? Some Pages it's working perfectly but getting error in this page..? anybody can help me..! Image also attached![77791-screenshot-2021-03-15-155911.png][1] [1]: /api/attachments/77791-screenshot-2021-03-15-155911.png?platform=QnA

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,641 questions
0 comments No comments
{count} votes

Accepted answer
  1. Karen Payne MVP 35,386 Reputation points

    Looks like you have used the wrong column name, run the following before the failing code to get column names to verify the column name.

    foreach (DataGridViewColumn dataGridViewColumn in studentsDataGridView.Columns)

0 additional answers

Sort by: Most helpful