简体   繁体   中英

Calculating values on web page in asp.net

I am having a ASP.net web page. It is some sort of order page ...

we have table on that page. the columns are Name of product, unit price, Quantity, Total price of the product. there are multiple products in rows of table

The Quantity column have TextBox for inputting the value.

I have one Calculate button... on clicking that the Total Price column should display the calculated value of products.

on button click all products rows "Total Price" column should display calculated value (Quantity * UnitPrice)

I am not getting how to achieve that, as im new to ASP.NET.

Any Idea ?

检查此示例,我已使用jQuery jQuery:.each()

If you have hard coded your table as your comments suggest then why not just do

int ProductOneTotal = (int)ProductOnePrice.Text * (int)ProductOneAmount.Text;
int ProductTwoTotal = (int)ProductTwoPrice.Text * (int)ProductTwoAmount.Text;

      ...and so on for each product and then.

int ProductTotal = ProductOneTotal + ProductTwoTotal + ....the rest;

Leaving you with ProductTotal which is the total value.

Here's another one that doesn't reach for jQuery.

http://jsfiddle.net/adrianjmartin/gr5Fr/25/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM