验证后面gridview代码中的文本框 [英] validate text boxes inside gridview code behind

查看:78
本文介绍了验证后面gridview代码中的文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我已经创建了一个动态多个文本框的网格视图。

我希望这些文本框只输入代码后面的数字。

一些建议我是一个合适的答案。

hello, I have created a grid view with multiple text boxes dynamically.
I want those text boxes to enter only numbers in code behind only.
some one suggest me a suitable answer.

推荐答案

禁用它们)像
myTextBox.Enabled = false;





在这种情况下,用户将无法更改文本框中的值。



编辑要验证数字,您应该编写一个方法,当文本框中的文本发生更改时(从文本框中的事件中取出),它应该检查,如果有的话只是数字。



In this case user would not be able to change value in textbox.

Edit To validate numbers, you should write a method, that will occur when text in textbox is changed (take from events in textbox) and it should check, if there are only numbers or not.


您可以使用 RegularExpressionValidator 获取 TextBox



参考 - Re:如何在Gridview文本框中验证为数字 [^ ^
You can use RegularExpressionValidator for that TextBox.

Refer - Re: How validate in Gridview textbox as numeric[^] for one Example.


单击网格事件写入代码以检查文本框编辑。如果两个condistion满意,你可以去正则表达式,允许用户只输入数字[0-9]某种东西。



这样你就可以实现你的欲望功能。



_SG
on click of the grid event write code to check for the text box editing. if both condistion satisfied than you can go for regular expression which allow user to enter only numeric [0-9] something kind of.

in this way you can achieve your desire functionality.

_SG


这篇关于验证后面gridview代码中的文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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