praveen kumar

praveen kumar

  • NA
  • 188
  • 30.7k

ERROR: Specified cast is not valid.

Apr 29 2015 5:20 AM
Hi,
 
 In datagridview, i am calculating(SUM) the timespan of the whole column, for the i am using the following code but it showing error "Specified cast is not valid.". kindly help me to sort out this issue
 
TimeSpan sum = TimeSpan.Zero;
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
sum += (TimeSpan)dataGridView1.Rows[i].Cells[4].Value;

}
label2.Text = sum.ToString(); 

Answers (1)