Tech
Forums
Jobs
Books
Events
Live
Interviews Prep
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
3
Reply
sum of datagridview values
Shyja Abraham
Feb 7 2011 4:01 PM
8.2k
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;
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
3
)
Next Recommended Forum
Storing SQL Select Results into Variable
Japanese text to speech conversion