[英]ASP.NET and SQL Adding value of two table cell in a row and saved in third cell of the row
My question is very simple, I have a table with four columns and those are: 我的问题很简单,我有一个包含四列的表,它们是:
ID int
value01 int
value02 int
total int
In the asp.net page the user will insert in a textbox the value of value01 and value02 and automatically the total will add the value of both of those columns without the need of a user doing anything. 在asp.net页中,用户将在文本框中插入value01和value02的值,并且总计将自动添加这两个列的值,而无需用户执行任何操作。
Also the table will have multiple rows therefore the total of one row should be the value01
and value02
addition of that current row ? 该表还将具有多行,因此,总的一行应为该当前行的value01
和value02
加法?
customize below javascript to your grid 自定义以下javascript到网格
function sum() {
var txtFirstNumberValue = document.getElementById('<%= txtjirayat1.ClientID %>').value;
var txtSecondNumberValue = document.getElementById('<%= txtbagayat1.ClientID %>').value;
var txtthirdno = document.getElementById('<%= txtpad.ClientID %>').value;
var result = parseFloat(txtFirstNumberValue) + parseFloat(txtSecondNumberValue) + parseFloat(txtthirdno);
if (!isNaN(result)) {
document.getElementById('<%= txttotal.ClientID %>').value = result;
}
}
尝试这个
Update TableName Set total = value01 + value01 Where Id = @ID
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.