I have a gridview in winforms which displays bill details. There is a column named total
. I created a label with a text "0". Then I used a for loop to get the sum of total
column in labels text property.
decimal tot1 = 0;
for (int i = 0; i < dgv_SaleReport.RowCount - 1; i++)
{
tot1 += Convert.ToDecimal(dgv_SaleReport.Rows[i].Cells[7].Value);
}
label_Total1SaleReport.Text = tot1.ToString();
But this code is not working. I added same code in other menu items datagridview and it's working. Right now, I have a tabcontrol which has 4 tabs. In all these 4 tabs dgv the code is not working. Can't just figure it out.