简体   繁体   English

在ASP.NET中的网页上计算值

[英]Calculating values on web page in asp.net

I am having a ASP.net web page. 我有一个ASP.net网页。 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. 作为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. 剩下的是ProductTotal,这是总价值。

Here's another one that doesn't reach for jQuery. 这是jQuery所不具备的。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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