Skip to content
Loading
   and your jquery code goes like this 
  1. $(document).ready(function () {    
  2.         var tr;    
  3.          var grandTotal = 0;  
  4.         $.getJSON("/QuotationMgt/GetQuotationDetails", function (json) {    
  5.             $.each(json, function (i, emp) {    
  6.                 var empid = emp.Id;    
  7.                 tr = $('');    
  8.                 tr.append("" + emp.Id + "");    
  9.                 tr.append("" + emp.damageName + "");    
  10.                 tr.append("" + emp.damageCondition + "");    
  11.                 tr.append("" + emp.lvlCode + "");    
  12.                 tr.append("" + emp.laborCost + "");    
  13.                 tr.append("" + emp.partsCost + "");    
  14.                 tr.append("" + emp.totalCost + "");    
  15.                 tr.append("" + " + empid + ">Delete");    
  16.                 grandTotal = grandTotal + emp.totalCost;  
  17.                 $('#tblEmployee').append(tr);    
  18.             });    
  19.            $("#lblTotal").text(grandTotal);  
  20.         });    
  21.     
  22.         $('#tblEmployee').on('click', 'td a.delete', function () {    
  23.             var deleteUrl = $(this).attr("href");    
  24.             if (confirm("Are you sure wants to delete?")) {    
  25.                 $.ajax({    
  26.                     url: deleteUrl, dataType: "json", type: "POST", contentType: "application/json",    
  27.                     error: function (err) { alert('Unable to delete record.'); },    
  28.                     success: function (response) {    
  29.                           
  30.     
  31.                         window.location.href = "/QuotationMgt/CreateQuotationDetail/" + @ViewBag.quotationNo;    
  32.                     }    
  33.                 });    
  34.             }    
  35.         });    
  36.     });    
+1
  • Rajanikant Hawaldar
    0
    Hi Dear,
     
     
    1. Int32 tot = 0;   
    2. protected void Dg_Source_RowDataBound(object sender, GridViewRowEventArgs e)  
    3. {  
    4.     if (e.Row.RowType == DataControlRowType.DataRow)  
    5.     {  
    6.         tot = tot + Convert.ToInt32(e.Row.Cells[1].Text);  
    7.         lblSum.Text = tot.ToString();  
    8.     }  
    9. }  
    0
  • Jes Sie
    0
    Hi Rajanikant, thanks for your reply. But, this is not asp.net webforms. This is MVC.
    0
  • Rajanikant Hawaldar
    0
    check this 
     as per your requirement
    https://techbrij.com/sum-total-avg-table-footer-asp-net-mvc-razor 
     
    this one is by using css to table column and change code accordingly
     
    https://stackoverflow.com/questions/27017507/how-to-get-a-sum-of-column-of-gridview-using-javascript 
    0
  • Jignesh Kumar
    0
    Hi Hold on,
     
    Please try this link,
     
    https://www.dotnetcurry.com/jquery/1189/jquery-table-calculate-sum-all-rows 
    0
  • Jes Sie
    0
    Hello Priyanka, I tried your suggestion but it gaves me this wierd result
     
    0
  • Priyanka Jain
    0
    Hi Hold,
     
    Please make sure that you are adding numbers , try converting your totalcost to decimal or int and check in console . If still remain unresolved. Please post your code here.
    0
  • Jes Sie
    0
    Thanks everyone for all of your inputs.
     
    I've already solve my problem using my own way. Though, probably this process takes longer to display the result but as of now, it gives me the result that I need.
     
    I simply get the total from my database and display the result using jquery.
     
    Again, thanks for all your inputs. 
    0