Click here to Skip to main content
16,018,264 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Sum calculation based on Checkbox responses.

Inside The My Gridview last Colum is checkbox Colum.User checkd same Checkboxs.
I need a automatically Calulate a Sum of related value of this row.

Ex: This is my Grid.User checked Seq 1 And 3.i need a get sum of this Amount Real time(User check time)

Note: Am not Hope 1st User Check And Add same button.it is time waste for my Function
Seq             Amout       CheckBox
 1             100.002             200.00         -
 3             300.00

Total:400.00

Anyone Can help me. Thank You!
Posted
Updated 17-Feb-14 21:40pm
v4

1 solution

in checkbox_checked() event, write the following code

C#
int amount=0;
for (int i=0;i<grid.rows.count;i++)>
{
   CheckBox chkBox=(CheckBox)grid.FindControl("chkBox");

   if(chkBox.Checked)
   {
      amount+=Convert.ToInt32(dtGridData.Rows[i]["Amount"]);
   }
}
lblTotal.Text=amount;
 
Share this answer
 

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