如何在Gridview文本框中验证为数字

问题描述:



我有一个gridview和最后一列作为数字列.

我想验证,GridView文本框应只允许数字.

如何做到这一点..?

Hi,

I have one gridview and last column as numeric columns.

I want to validate and gridview textbox should allow only numeric.

Ho to do this..?

我发现 ^ ]是在不久前问到的.
此处给出的解决方案相当准确,应该可以为您提供帮助.
I found this[^] had been asked some time ago.
The solutions given there are fairly accurate and should help you out.


假设您希望使用类型int.验证文本框属性Text的唯一可靠方法是调用int.TryParse(string).

请参阅 http://msdn.microsoft.com/en-us/library/f02979c7.aspx [ ^ ].

其他所有整数类型也是如此.

—SA
Suppose you expect the type int. The only reliable way to validate the property Text of the text box is to call int.TryParse(string).

See http://msdn.microsoft.com/en-us/library/f02979c7.aspx[^].

Same thing goes for all other integer types.

—SA