Gridview footer template textbox not Calculating rate*Quantity = Total RRS feed

  • Question

  • User-807418713 posted


    This is my javascript

    <script type="text/javascript">
        function FootLabel()
            var txtFirstNumberValue = document.getElementById('ctl00_ContentPlaceHolder1_Label10').innerText;
            var txtSecondNumberValue = document.getElementById('ctl00_ContentPlaceHolder1_GridView3_ctl10_FPW').value;
             var result =  parseFloat(txtFirstNumberValue) * parseFloat(txtSecondNumberValue);
             document.getElementById("ctl00_ContentPlaceHolder1_GridView3_ctl10_FAQ").value = result;

    its not working gridview footertemplate textbox why

    some times it coming ctl10, some time ctl12,

    any best method to solve this issue

    im using asp.net with Masterpage

    Tuesday, October 23, 2018 12:27 PM


  • User839733648 posted


    According to your description and code, I suggest that you could add specific ids to the column of rate,Quantity,Total in FootTemplete and then set the values.

    You have to add ClientIDMode="Static" to the related labels.

    You could modify your code as below.

                var txtFirstNumberValue = document.getElementById("rateTotal").innerHTML;
                var txtSecondNumberValue = document.getElementById("quantityTotal").innerHTML;
                document.getElementById("AvgTotal").innerHTML = parseFloat(txtSecondNumberValue) * parseFloat(txtFirstNumberValue);
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" ShowFooter="true">
                <asp:TemplateField HeaderText="Rate">
                        <asp:Label ID="rateTotal" runat="server" ClientIDMode="Static"></asp:Label>
                <asp:TemplateField HeaderText="Quantity">
                        <asp:Label ID="quantityTotal" runat="server" ClientIDMode="Static"></asp:Label>
                <asp:TemplateField HeaderText="Avg">
                        <asp:Label ID="AvgTotal" runat="server" ClientIDMode="Static"></asp:Label>

    result like this:

    Best Regards,


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 24, 2018 4:46 AM