本文介绍了datagrid文本框值必须大于零。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我在datagrid中有文本框。我的要求是,Textbox必须大于零值。当用户在文本框中输入零并且在尝试保存时,它不应该允许保存记录。应该提示值必须大于零如何使用javascript或C# 我的代码 - < asp:DataGrid ID = dgProductList 样式 = overflow:auto runat = server AllowPaging = True GridLines = 两者 BorderWidth = 1 CssClass = gridbody CellSpacing = 1 AutoGenerateColumns = False PageSize = <% $ AppSettings:GridViewPageSize %> CellPadding = 0 > < asp:TemplateColumn HeaderStyle-CssClass = gridheader > < HeaderStyle Horizo​​ntalAlign = 中心 / > < HeaderTemplate > 数量< sup class = ErrorSymbol > * < / sup > < / HeaderTemplate > < ItemTemplate > < asp:TextBox ID = TxtQuantity runat = 服务器 样式 = width:50px; text-align:center MaxLength = 6 CssCla ss = GridTextbox 文字 =' <% #Bind( prod_quantity)%> ' > < / asp:TextBox > <% - < asp:RequiredFieldValidator id = RFVQuantity CssClass = text ControlToValidate = TxtQuantity runat = server ErrorMessage = 请输入数量显示= none > < / asp:RequiredFieldValidator > - %> < / ItemTemplate > < / asp:TemplateColumn > < / asp:DataGrid > 解决方案 AppSettings:GridViewPageSize %> CellPadding = 0 > < asp:TemplateColumn HeaderStyle-CssClass = gridheader > < HeaderStyle Horizo​​ntalAlign = 中心 / > < HeaderTemplate > 数量< sup class = ErrorSymbol > * < / sup > < / HeaderTemplate > < ItemTemplate > < asp:TextBox ID = TxtQuantity runat = server 样式 = 宽度:50px; text-align:center MaxLength = 6 CssCla ss = GridTextbox 文字 =' <% #Bind( prod_quantity)%> ' > < / asp:TextBox > <% - < asp:RequiredFieldValidator id = RFVQuantity CssClass = text ControlToValidate = TxtQuantity runat = server ErrorMessage = 请输入数量显示= none > < / asp:RequiredFieldValidator > - %> < / ItemTemplate > < / asp:TemplateColumn > < / asp:DataGrid > 使用CompareValidator < asp:CompareValidator runat =serverid =compTxtQuantity Operator =GreaterThanType =Integer Display =DynamicValueToCompare =0 ControlToValidate = TxtQuantity ErrorMessage =您必须输入一个大于零的值。 /> Hi, I have textbox inside datagrid. my requirement is , Textbox must be greater than zero value.While user enters zero into textbox and while trying to save, it should not allow to save record.it should give prompt value must be greater than zero How t do using javascript or C#My code--<asp:DataGrid ID="dgProductList" Style="overflow: auto" runat="server" AllowPaging="True"GridLines="Both" BorderWidth="1" CssClass="gridbody" CellSpacing="1" AutoGenerateColumns="False"PageSize="<%$ AppSettings: GridViewPageSize %>" CellPadding="0"><asp:TemplateColumn HeaderStyle-CssClass="gridheader"> <HeaderStyle HorizontalAlign="Center" /> <HeaderTemplate> Quantity<sup class="ErrorSymbol">*</sup></HeaderTemplate> <ItemTemplate> <asp:TextBox ID="TxtQuantity" runat="server" Style="width: 50px; text-align: center" MaxLength="6" CssClass="GridTextbox" Text='<%#Bind("prod_quantity") %>'></asp:TextBox> <%--<asp:RequiredFieldValidator id="RFVQuantity" CssClass="text" ControlToValidate="TxtQuantity" runat="server" ErrorMessage="Please Enter Quantity" Display="none"></asp:RequiredFieldValidator>--%></ItemTemplate> </asp:TemplateColumn> </asp:DataGrid> 解决方案 AppSettings: GridViewPageSize %>" CellPadding="0"><asp:TemplateColumn HeaderStyle-CssClass="gridheader"> <HeaderStyle HorizontalAlign="Center" /> <HeaderTemplate> Quantity<sup class="ErrorSymbol">*</sup></HeaderTemplate> <ItemTemplate> <asp:TextBox ID="TxtQuantity" runat="server" Style="width: 50px; text-align: center" MaxLength="6" CssClass="GridTextbox" Text='<%#Bind("prod_quantity") %>'></asp:TextBox> <%--<asp:RequiredFieldValidator id="RFVQuantity" CssClass="text" ControlToValidate="TxtQuantity" runat="server" ErrorMessage="Please Enter Quantity" Display="none"></asp:RequiredFieldValidator>--%></ItemTemplate> </asp:TemplateColumn> </asp:DataGrid>use CompareValidator<asp:CompareValidator runat="server" id="compTxtQuantity" Operator="GreaterThan" Type="Integer" Display="Dynamic" ValueToCompare="0" ControlToValidate="TxtQuantity" ErrorMessage = "You must enter a value greater than zero." /> 这篇关于datagrid文本框值必须大于零。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-04 03:07