简体   繁体   English

ASP.NET和SQL将两个表单元格的值相加并保存在该行的第三个单元格中

[英]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 ? 该表还将具有多行,因此,总的一行应为该当前行的value01value02加法?

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.

相关问题 asp.net gridview如果单元格行值相等,则 - asp.net gridview if cell row value is equal then ASP.NET GridView - 无法获取上一行中单元格的值 - ASP.NET GridView - Unable to get value of cell in previous row 如果我有来自此行的单元格值,请在Asp.net的GridView控件中获取行的索引。 - Get index of row in GridView Control in Asp.net if i have a value of a cell from this row.? 如何基于asp.net gridview控件中的表行的单元格的特定值显示下拉列表中的特定项目? - How to show a specific item in dropdownlist based on specific value of a cell of a table-row in asp.net gridview control? 无法从gridview中的行单元格中删除属性| asp.net - Cannot remove the attribute from row cell in gridview | asp.net 如何从ASP.NET C#中的GridView获取单击的超链接行相邻单元格值 - How to get clicked hyperlink row adjacent cell value from GridView in ASP.NET C# 逐行读取SQl表并更新单元格 - Read SQl table row by row and update a cell 如果两个表列的值相同,asp.net更改gridview单元格 - asp.net change gridview cell if two table columns got the same value Asp.net OnClientClick显示表中其他单元格的值 - Asp.net OnClientClick show value from other cell in table 在ASP.NET表中添加一行会覆盖之前的行 - Adding a row to an ASP.NET table overwrites previous rows
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM