[Solved] ASP.Net GridVeiw column Multiply is not working with TemplateField using jQuery

on May 23, 2022 01:37 AM

as per reference

[Solved] Multiply two columns in ASP.Net GridView using jQuery

I change column from

<asp:BoundField ItemStyle-Width="150px" DataField="rate" HeaderText="Rate" />


<asp:TemplateField HeaderText="Rate">
        <asp:Label ID="rate" Width="50px"  runat="server" Text='<%#Bind("rate")%>'></asp:Label>

Then multiplication is not working

Download FREE API for Word, Excel and PDF in ASP.Net: Download
on May 23, 2022 01:40 AM

Hi akhter,

Use below code.

<script type="text/javascript">
    $(function () {
        $("body").on("change keyup", "[id*=orderqty]", function () {
            //Check whether Quantity value is valid number.
            var quantity = $.trim($(this).val());
            if (isNaN(quantity)) {
                quantity = 0;
            //Update the Quantity TextBox.

            var row = $(this).closest("tr");

            //Check whether Rate value is valid number.
            var rate = $("[id*=rate]", row).html();
            if (isNaN(rate)) {
                rate = 0;
            $("[id*=rate]", row).html(rate);

            //Calculate and update Row Total.
            $("[id*=lbtotal]", row).html(parseFloat(rate) * parseFloat(quantity));

            //Calculate and update Grand Total.
            var grandTotal = 0;
            $("[id*=lbtotal]").each(function () {
                grandTotal = grandTotal + parseFloat($(this).html());