如何将验证器放置到数据网格中的文本框 [英] How to place validator to the textbox in a datagrid

查看:54
本文介绍了如何将验证器放置到数据网格中的文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在数据网格中放置了一个文本框.我想向该文本框添加一个验证器,以便不能在其中输入任何字符,只能输入整数.请帮助.

I have placed a textbox in a datagrid.I want to add a validator to the textbox so that no characters can be entered into it, only integers should be entered.Plz Help.

推荐答案

选项1:
在Grid内这样的事情怎么样:
OPTION 1:
How about something like this inside the Grid:
<EditItemTemplate>
   <asp:TextBox id="txtReceived"></asp:TextBox>
   <asp:customvalidator id="cvalReceived" runat="server" ClientValidationFunction="ValidateReceivedAmounts" ControlToValidate="txtReceived">
   </asp:customvalidator>
</EditItemTemplate>



选项2:
使用Javascript验证.使用属性将Javascript方法添加到客户端onKeyDown.现在,在JavaScript中,检查输入的值,如果不是整数则显示错误,或者只是取消按下的键.



OPTION 2:
Use Javascript validation. Add a Javascript method to the client side onKeyDown using attributes. Now, in JavaScript, check the value entered and show error if not integer or just cancel out the key pressed.


这篇关于如何将验证器放置到数据网格中的文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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