Click here to Skip to main content
15,886,830 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello!!!

I have a gridview. There is a checkbox column inside gridview. what i need is as soon as user clicks checkbox for any row value should be calculated and shown in a template field in the same row.
I dont need to do this on some button click event Outside gridview as i have done that what i want is it should be done inside gridview as soon as checkbox is checked.


thanks!!
Posted
Comments
dimpledevani 18-Jul-12 7:32am    
use the checkedchange event of checkbox

I suggest using javascript for this task (to prevent postback for each click)

give all your checkboxes an data-rowId attribute and each row the same id.
give all your textboxes a class (or other attribute) to know which ones to calculate.

Then add an event on all your checkboxes.

JavaScript
$('input[type="checkbox"]').on('click', function(){
   var rowId = $(this).attr('data-rowId');

   var sum = 0;
   $('#'+rowId+' input.calculateMe').each(function(){   
      var currentTextbox = $(this);
      var val = parseFloat(currentTextbox.val());
      sum += val;
   });

   $('#txtSumEveryting').val(sum);
});
 
Share this answer
 
v2
hi,

you can do it in gridview itemdatabound event where you can find id of that record on checkbox click. and there you will have values for calculations and store in where you want.
 
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