Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
3
Answers
sum of datagridview values
Shyja Abraham
13y
8.2k
1
Reply
I have form with datagridview with columns id,name,mark .and a textbox total.Iwant to find the sum of the mark when we entered the values into the datagridview.
int sum=0;
private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
{
sum += Convert.ToInt32(dataGridView1.Rows[i].Cells["mark"].Value.ToString());
textBox1.Text = Convert.ToString(sum);
}
}
but the "Object reference not set to an instance of an object" error occurs, plz help;
Post
Reset
Cancel
Answers (
3
)
Next Recommended Forum
Storing SQL Select Results into Variable
Japanese text to speech conversion