如何在gridview列中计算金额 [英] How to calculate amount in gridview column

查看:147
本文介绍了如何在gridview列中计算金额的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有gridview,其中有4个cloumns,如下拉列表,显示产品,费率列,数量列和总金额列我希望当我输入费率和数量总金额显示自动计数。

亲切指导我



虽然我也尝试了gridview rowdatabound中的代码,但它显示字符串格式不正确



我尝试过:



i have gridview in which there 4 cloumns like dropdownlist which shows products, Rate Column, Quantity Column and Total Amount Column i want that when i enter rate and quantity total amount show automatically count.
kindly guide me

while i also tried code in gridview rowdatabound but it shows string was not in correct format

What I have tried:

for (int i = 0; i < GridView1.Rows.Count; i++)
            {

               
               GridView1.Rows[i].Cells[3].Text = Convert.ToString(Convert.ToInt32(GridView1.Rows[i].Cells[1].Text.Replace('-', ',')) * Convert.ToDouble(GridView1.Rows[i].Cells[2].Text.Replace('-', ',')));

            }

推荐答案

使用JavaScript等客户端脚本,这样就不需要了往返服务器。使用jQuery的JavaScript库检查此示例:

使用jQuery在ASP.Net GridView中计算行总计和总计 [ ^ ]
Use client-side script such as JavaScript so that there is no need to have a round trip to the server. Check this example using a JavaScript library of jQuery:
Calculate Row Total and Grand Total in ASP.Net GridView using jQuery[^]


这篇关于如何在gridview列中计算金额的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆