Click here to Skip to main content
15,892,697 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi,

I have a grid with 3 columns. while entering into a textbox, will change other amount column value. Amount column is read only. Then sum of this textbox must be update in the label of a footer in textbox changed event .

please help me..

Thanks in advance..

Vineetha
Posted
Comments
Maciej Los 24-Jul-14 16:13pm    
Not a question at all!

You need to write javascript or jquery for this rather then writing on textbox change event, second thing make sure you put some code in your question that you have tried uptill now, don't just describe in words what you want.

Refer this links:
1. Calculate Row Total and Grand Total in ASP.Net GridView using jQuery

2. Gridview item template column total using jquery or javascript
3. Calculating GridView total using JavaScript/JQuery
 
Share this answer
 
Comments
Vineetha Ravindranath 25-Jul-14 7:42am    
I can calculate the value.
I have to show grand total in footer label and in a textbox..

please check my script
<script type="text/javascript">
$(function () {
$("[id*=txtQuantity]").val("0");
});
$("[id*=txtQuantity]").live("change", function () {
if (isNaN(parseInt($(this).val()))) {
$(this).val('0');
} else {
$(this).val(parseInt($(this).val()).toString());
}
});
$("[id*=txtQuantity]").live("keyup", function () {
if (!jQuery.trim($(this).val()) == '') {
if (!isNaN(parseFloat($(this).val()))) {
var row = $(this).closest("tr");
var smt = parseFloat($("[id*=lblRate]", row).html()) * parseFloat($(this).val());
var hid = (parseFloat($("[id*=lblRate]", row).html()) * parseFloat($(this).val())).toFixed(2);
$("input[id*='txtAmount']", row).val(hid);

}
} else {
var row = $(this).closest("tr");
$("input[id*='txtAmount']", row).val("0");
$(this).val('');
}

var total = 0.00;
$("#gv1 input[id $= 'txtAmount']").each(function () {
var value = $(this).val();
total = parseFloat(total) + Math.round(parseFloat(value));
});
$("#lblTotalAmount").val(total);
$("#txtTotalAmount").val(total);
});
</script>

lblTotalAmount is footer label.

txtTotalAmount is a normal text box outside the gridview.
Hi,

You can do this by using Asp.Net and you probably do not need any client script do get the Sum of GridView Column values in the Footer. Its written both in C# and Vb.Net. It also handles "paging" issues, such as how to get the sum in each page of the GridView along with the Grand total, shown in every page (if GridView paging in enabled).

Happy coding.

Arun
 
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