如何在DataGrid视图中验证单元格中的十进制值 [英] how to validate decimal value in a a cell in datagrid view

查看:109
本文介绍了如何在DataGrid视图中验证单元格中的十进制值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我在vb.net Windows应用程序中使用gridview.在网格视图中,前两个单元格是字符串值,第三个单元格我们必须输入十进制值.请有人帮我验证一下,例如不允许按下跟随键az [a-zA -Z] [\ w \ .-] * [a-zA-Z0-9] @ [a-zA-Z0-9] [\ w \ .-] * [a-zA-Z0-9] \. a-zA-Z] [a-zA-Z \.] * [a-zA-Z] $.仅允许按整数和.".

解决方案

.只允许按整数和.".


使用网格中的模板列

并定期进行如下操作

 <   asp:RegularExpressionValidator     ID   ="   ="span>    runat   =" 服务器" 
                                                                                                                                    ControlToValidate   ="  txtDecimal"  ErrorMessage   ="  
                                                                                                                                   文本  ="  *"  Val idationExpression   ="  宽度   1像素" "><  /asp:RegularExpressionValidator  >  


hi i am using gridview in vb.net windows applications.in the grid view first two cells are string value and the 3rd cell we have to enter decimal values.please someone help me to validate like not allow to press follwing keys a-z[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$.and only allow to press integer and ".".

解决方案

.and only allow to press integer and ".".


use template column in grid

and have a regular experssion like below

<asp:RegularExpressionValidator ID="REVtxtDecimal" runat="server"

                                                                            ControlToValidate="txtDecimal" ErrorMessage="decimal Value-Enter only numerics.Format like (x.xx)"

                                                                            Text="*" ValidationExpression="^\d+(\.\d\d)?


" Width="1px"></asp:RegularExpressionValidator>


这篇关于如何在DataGrid视图中验证单元格中的十进制值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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