How to sum of two rows values inside the datagridview c#
How to sum of two rows values inside the datagridview, if the id of the both rows same and create one rows instead of two rows in the datagrid
or
and for the multiple rows values
like the following example:
id quantity Bonus price total
01 25 10 123 4305
01 5 10 123 1845
i want to sum of the above two rows like this in the datagrid
id quantity Bonus price total
01 30 20 123 6150
if i take loop on it then duplicate value insert in the datagridview.
like my code
For example:
for(int i=0; i<datagridview.rows.count; i++)
{
if(datagridview.rows[i].cells[0].value==txtid.Text)
{
if(comboboxtype=="Stock")
{
//For Stock
///updation code,if value exist in the datagrid
}
else
{
//For Bonus
///updation code,if value exist in the datagrid
}
}
else
{
if(comboboxtype=="Stock")
{
//For Stock
/// ///Insertion code, if value does not exist in the datagrid
}
else
{
/// For Bonus
/// ///Insertion code, if value does not exist in the datagrid
}
}
}
plz, Anyone can help me ..............