.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

calculate running total when entering quantity in gridview ..

Posted By: gopal     Posted Date: February 15, 2011    Points:2   Category :ASP.Net

i have a gridview..

in tat i was binding the table values like name,price and two textboxes for quantity and another one for total textbox for calulating total depends on quantity with price.


if i entering some quantities during tat time it will calculate the total value and displayed in total textbox of the corresponding row..
i dont want to use button to calculate the total value for each rows.
i dont want to use button to calculate the total value for each rows.

how to do this..

Wat is the easy way to do this..

need ur suggestions with examples..


Author: Sunil Yadav       [Moderator]      
Posted Date: February 15, 2011     Points: 5   

Hi gopal,

You can achieve this on Text_Changed event of the Quantity Textbox .
Make sure you set the AutoPostack property of text box to True in order to fire the event.

let me know if you need any help.

Author: Blessy Baby             
Posted Date: February 15, 2011     Points: 5   


I would suggest to use javascript for calcualting total amount

Add "onchange" event for quantity textbox in grid databound event

// this code in repeater item databound, you can do same for gridview
TextBox txtQty = item.FindControl("txtquantity") as TextBox;
TextBox txtPrice = item.FindControl("txtPrice") as TextBox;
TextBox txtTotal = item.FindControl("txtTotal") as TextBox;

txtQty .Attributes.Add("onchange", "return fnTest('" + txtQty .ClientID + "','"+txtPrice.ClientID +"','"+txtTotal.ClientID +"')");

and add javascript function in aspx page

function fnTest(qty,price,total) {
d1 = document.getElementById(qty);
d3= document.getElementById)total);
this is basic idea you can make other neccessary cahnges

Blessy Baby
Project Lead
Digitalmesh Softech India (p) Limited

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend