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();
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
sum += (TimeSpan)dataGridView1.Rows[i].Cells[4].Value;
}
label2.Text = sum.ToString();
Vishwakant TripathiPosted Apr 29, 2015, 5:49 AM
sum+= TimeSpan.Parse(dataGridView1.Rows[i].Cells[4].Value);