带有Rad掩码的文本框可以接受整数 [英] Rad masked text box to accept integers

查看:105
本文介绍了带有Rad掩码的文本框可以接受整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我将rad掩码文本框用于数字输入.当我将值传递给数据库时,前面的0(如果有的话)会自动被截断.我还尝试了rad数字文本框,但即使在将值传递给数据库之前,它也会截断前面的0.在我的数据库中,我有一列可以接受0到9之间的6位数字.我为此定义了检查约束,该值不能少于6位.因此,如果从rad数值文本框或掩码文本框输入的内容从0开始,例如012345,则0会自动在rad数值文本框中被截断.
使用带遮罩的文本框时,控件将值传递为012345,但sql server会截断前面的0.

请帮助解决问题.

注意:客户确实希望使用javascript进行验证...

提前谢谢...

感谢Aday和Griff对您的评论和建议,但问题仍然令人怀疑.我无法将表的数据库结构更改为接受字符串.所以我需要将值作为整数传递给数据库.让我澄清一下...

某些供应商在radmasked文本框或radinumeric文本框中输入了6位数字(012345)否.因此,当我将值传递给用于插入语句的存储proc时,必须将其作为整数传递. 1.如果sql截断前导零(01 = 1),那么我必须存储所有六位数字的解决方案是什么?否则检查该列的约束将给出错误?
2.如果sql没有截断前导零,则int.parse(radmaskedtextbox1.text)会将其转换为012345或12345?

如果您可以澄清..这将是一个很大的帮助...

Hi I am using a rad masked textbox for numeric inputs. When I pass the value to database the preceding 0 if any is automatically truncated. I also tried rad numeric text box but it also truncates the preceding 0 even before passing the value to database. In my db i have a column to accept 6 digits from 0-9 each. I have check constraints defined for that and the value cannot be less than 6 digits. So if the input from rad numeric text box or masked text box starts from 0 like 012345, the 0 automatically gets truncated in rad numeric text box.
when using masked text box the control passes the value as 012345 but sql server truncates the preceding 0.

Pls help to resolve the issue.

Note: Clients does to want to use javascript for validation...

Thanks in advance...

Thanks Aday and Griff for ur comment and suggestion but the issue is quite dubious. I can''t change the database structure of the table to accept string. So what I need is to pass the value as integer to the database. Let me clarify u...

Some vendor entered a 6 digit (012345) no to the radmasked text box or radnumeric textbox. So when i pass the value to the stored proc for insert statement it must me passed as integer..
1. if sql truncates leading zeros (01 =1) what is the solution as I have to store all six digits or else check constraint for the column will give error?

2. If sql does not truncate the leading zero then int.parse(radmaskedtextbox1.text) will convert it into 012345 or 12345?

If u can clarify.. It will be a great help...

推荐答案

数字是数字就是数字.
就整数而言,1等于0000001与000000000000000000000000000000000000000000000000000000000000000000000000000000000001相同,或者就整数解析器而言-前导零不计数.
如果必须将六位数的值传递给SQL,则它必须没有任何前导零,或者必须作为字符串传递-完全转换为整数值将丢弃任何数量的前导零.
Numbers are numbers are numbers.
1 is the same as 0000001 is the same as 000000000000000000000000000000000000000000000000000000000000000000000001 as far as an integer, or an integer parser is concerned - leading zeros do not count.
If you must pass a six digit value to SQL, then it must either not have any leading zeroes, or it must bne passed as a string - any conversion to an integer value at all will discard any number of leading zeroes.


这篇关于带有Rad掩码的文本框可以接受整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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