Muhammad Shah

Muhammad Shah

  • NA
  • 4
  • 2.8k

How to get average of column of grid in case of null entry?

Dec 16 2015 4:08 PM
I want to get the sum and also the average of GridView column .If there is any "null" entries in the column then it is not give me the sum.
int i = 0;
int j = 0;
int sum = 0;
try
{
for (i = 0; i < dataGridView1.Rows.Count - 1; i++)
{
for (j = 0; j < dataGridView1.Columns.Count; j++)
{
sum = sum + (Convert.ToInt32(dataGridView1.Rows[i].Cells[j].Value));
}
}
MessageBox.Show("sum"+sum);
}
I want to get average of the column and then place it in the null value cell.
any body help me
 
 

Answers (2)