Click here to Skip to main content
15,887,862 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i m havng a gridview, a previous value lable column called lbl_pre, text box column named txt_pre which is used to make entry , another label named lbl_sum column which will be used for previous value + user enter value
now my lbl_pre + txt_pre value working fine and lbl_sum shown correct output, but total of lbl_sum is not working.

What I have tried:

<script type="text/javascript">

         function Calctotal_pre(PreviousValue, txtvalue, TotalValue)
         {
             var uservalue = parseFloat(document.getElementById(txtvalue).value);
             var TotalVar = document.getElementById(TotalValue);

 var TotalValue = parseFloat(PreviousValue + uservalue );
             TotalVar.innerHTML = TotalValue;

                    var total_allPY = 0;
                     $($("[id*=GvList] [id*=lbl_sum]")).each(function ()
                     {
                         if (!isNaN(parseFloat($(this).val())))
                         {
                             total_allPY += parseFloat($(this).val());
                         }
                     });
           
                     $("[id*=GvList] [id*=lbl_PY_total]").html(total_allPY);
  }
 </script>

----------------CODE PART--------------

protected void GvList_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        { 
 Label lblList = (Label)e.Row.FindControl("lbl_pre");
            PreVal += Convert.ToDecimal(lblList.Text);

 txt_pre.Attributes.Add("onkeyup", "Calctotal_pre(" + PreVal  + ", '" + txtqut.ClientID + "','" + lbl_sum.ClientID + "')");
 }
 }
Posted
Updated 15-May-19 1:20am

1 solution

var total_allPY = 0;
$("[id*=lbl_sum]").each(function ()
{

total_allPY = total_allPY + parseFloat($(this).html());

});

$("[id*=lbl_PY_total]").html(total_allPY .toString());
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900