在int数据类型中转换eval的值. [英] converting value of eval in int data type..

查看:157
本文介绍了在int数据类型中转换eval的值.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在产品表中有一个价格列..我在数据列表中显示产品.问题是价格列的类型为money ..我想在数据列表的int数据类型中显示它..

我正在尝试使用Convert.ToInt16(Eval("UnitCost").ToString())..但它无法正常工作..任何人都可以致电给我正确的方法.方案

您正在尝试将字符串转换为int.为此,您需要TryParse.为什么要在整个过程中将其制成字符串?您可以使用Convert.ToInt16将双精度或十进制转换为int.

当您提出问题时,请不要说它不起作用",告诉我们发生了什么,并给我们提供任何错误消息.


i have a price column in a products table .. i am showing products in data list. problem is that price column is of type money.. i want to show it in int data type in data list..

i am trying to do it with Convert.ToInt16 (Eval("UnitCost").ToString()).. but its not working.. can anyone tel me the correct way of doing it.

解决方案

You''re trying to convert a string to an int. You need TryParse for that. Why make it a string along the way ? You can convert double or decimal to int with Convert.ToInt16.

When you ask a question, don''t say ''its not working'', tell us what happens and give us any error messages.


这篇关于在int数据类型中转换eval的值.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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