从asp.net的文本框中乘以两个值 [英] multiply two values from textbox in asp.net

查看:114
本文介绍了从asp.net的文本框中乘以两个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI ..

如何将文本框中的两个值相乘并将结果放入c#中的另一个文本框中...

这是我的代码,但出现错误,无法将类型"int"隐式转换为"strint" ........

HI..

How to multiply two values from textbox and put the result in another textbox in c#...

Here is my code but it getting error, Cannot implicitly convert type ''int'' to ''strint''.......

protected void txtqty_TextChanged(object sender, EventArgs e)
   {
       if (txtrate.Text != "")
       {
           txttamt.Text = ((Convert.ToInt32(txtrate.Text.Trim())) * (Convert.ToInt32(txtqty.Text.Trim())));
       }
   }




在SQL中,我将值数据类型存储为整数.......




In SQL i stored the values datatype as integer.......

推荐答案


请更改为
txttamt.Text =(((Convert.ToInt32(txtrate.Text.Trim()))*(Convert.ToInt32(txtqty.Text.Trim()))).ToString();
Hi,
Pls change as
txttamt.Text = ((Convert.ToInt32(txtrate.Text.Trim())) * (Convert.ToInt32(txtqty.Text.Trim()))).ToString();


使用以下代码:-
use below code:-
protected void txtqty_TextChanged(object sender, EventArgs e)
   {
       if (txtrate.Text != "")
       {
           txttamt.Text =Convert.tostring( ((Convert.ToInt32(txtrate.Text.Trim())) * (Convert.ToInt32(txtqty.Text.Trim()))));
       }
   }


尝试一下:

Try this one :

protected void txtqty_TextChanged(object sender, EventArgs e)
   {
       if (txtrate.Text != "")
       {
           txttamt.Text = (((Convert.ToInt32(txtrate.Text.Trim())) * (Convert.ToInt32(txtqty.Text.Trim())))).tostring();
       }
   }



我在这里所做的是,我在开头添加了一个括号,在末尾添加了一个括号,然后将整个语句转换为字符串.因此,您的错误是将整数放置在接受字符串的txttamt中.



What i did here is that i added a bracket at the beginning and another one at the end then converted the whole statement to string.So your error is that you are placing integers in txttamt which accepts strings.


这篇关于从asp.net的文本框中乘以两个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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