Click here to Skip to main content
15,893,904 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
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?

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
}


}
}



Please,Anyone Can help me
Posted
Updated 14-Sep-13 0:14am
v2
Comments
[no name] 14-Sep-13 6:15am    
"Can help me", sure... see http://www.codeproject.com/Questions/653157/How-to-sum-of-two-rows-values-inside-the-datagridv for answers.
OriginalGriff 14-Sep-13 6:15am    
Repost of same question from yesterday, already answered twice...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900