我是自动生成列的DataGrid.我在点编辑列(编辑).我想判断当前输入框不能为字母,和负数.应该怎么做啊!谢谢!

解决方案 »

  1.   

    <asp:datagrid id="DataGrid1" runat="server" Width="629px" BorderWidth="0px" AutoGenerateColumns="False"
    ShowFooter="True">
    <Columns>
    <asp:TemplateColumn>
    <HeaderTemplate>
    <table height="26" cellSpacing="0" cellPadding="5" width="100%" border="0">
    <tr>
    <td width="4%" height="26">
    <asp:CheckBox AutoPostBack="True" id="ckb_All" runat="server" OnCheckedChanged="AllSelect"></asp:CheckBox>
    </td>
    <td width="21%" height="26">商品名</td>
    <td align="center" width="12%" height="26">市场价</td>
    <td align="center" width="12%" height="26">会员价</td>
    <td align="center" width="13%" height="26">vip价</td>
    <td align="center" width="7%" height="26">数量</td>
    <td align="center" width="13%" height="26">支付总额</td>
    <td width="19%" height="26">
    <p align="right">操作</p>
    </td>
    </tr>
    <tr>
    <td width="97%" colSpan="8" height="26">
    <hr color="#c0c0c0" SIZE="1">
    </td>
    </tr>
    </HeaderTemplate>
    <ItemTemplate>
    <tr>
    <td width="4%" height="26">
    <asp:TextBox Visible=False id="ProductID" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"ProductID")%>'>
    </asp:TextBox>
    <asp:CheckBox id="ckb_Select" runat="server"></asp:CheckBox>
    </td>
    <td width="21%" height="26"><%# Ccshop.App_Code.INC.format.Substring(DataBinder.Eval(Container.DataItem,"ProductName").ToString(),30)%></td>
    <td align="center" width="12%" height="26">
    <strike>
    <%# String.Format("{0:c}",int.Parse(DataBinder.Eval(Container.DataItem,"ProductPrice").ToString()))%>
    <strike>
    </td>
    <td align="center" width="12%" height="26">
    <%# String.Format("{0:c}",int.Parse(DataBinder.Eval(Container.DataItem,"ProductPrice_h").ToString()))%>
    </td>
    <td align="center" width="13%" height="26">
    <%# String.Format("{0:c}",int.Parse(DataBinder.Eval(Container.DataItem,"ProductPrice_v").ToString()))%>
    </td>
    <td align="center" width="7%" height="26">
    <%#DataBinder.Eval(Container.DataItem,"Number")%>
    <asp:TextBox Width=20 ReadOnly=True Visible=False id="Number" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"Number")%>'>
    </asp:TextBox>
    </td>
    <td align="center" width="13%" height="26"><%# String.Format("{0:c}",int.Parse(DataBinder.Eval(Container.DataItem,"Totle").ToString()))%></td>
    <td width="19%" height="26">
    <p align="right"><asp:Button ID="ib_Edit" class="t2" Text="编辑" CommandName="Edit" runat="server" CausesValidation="False"></asp:Button></p>
    </td>
    </tr>
    </ItemTemplate>
    <EditItemTemplate>
    <tr bgcolor="#EFEFEF">
    <td width="4%" height="26">
    <asp:TextBox Visible=False id="eid" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"ProductID")%>'>
    </asp:TextBox>
    </td>
    <td width="21%" height="26"><%# Ccshop.App_Code.INC.format.Substring(DataBinder.Eval(Container.DataItem,"ProductName").ToString(),30)%></td>
    <td align="center" width="12%" height="26">
    <strike>
    <%# String.Format("{0:c}",int.Parse(DataBinder.Eval(Container.DataItem,"ProductPrice").ToString()))%>
    <strike>
    </td>
    <td align="center" width="12%" height="26">
    <%# String.Format("{0:c}",int.Parse(DataBinder.Eval(Container.DataItem,"ProductPrice_h").ToString()))%>
    </td>
    <td align="center" width="13%" height="26">
    <%# String.Format("{0:c}",int.Parse(DataBinder.Eval(Container.DataItem,"ProductPrice_v").ToString()))%>
    </td>
    <td align="center" width="7%" height="26">
    <asp:TextBox Width=30 id="have" runat="server" Visible=False Text='<%#DataBinder.Eval(Container.DataItem,"have")%>'>
    </asp:TextBox>
    <asp:TextBox Width=30 id="enum" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"Number")%>'>
    </asp:TextBox><asp:RegularExpressionValidator ControlToValidate="enum" id="RegularExpressionValidator1" runat="server" ErrorMessage="!"
    ValidationExpression="^([0-9]*|\d*)$"></asp:RegularExpressionValidator>
    </td>
    <td align="center" width="13%" height="26"><%# String.Format("{0:c}",int.Parse(DataBinder.Eval(Container.DataItem,"Totle").ToString()))%></td>
    <td width="19%" height="26">
    <p align="right"><asp:Button ID="Button1" class="t2" Text="修改" CommandName="update" runat="server"></asp:Button><asp:Button ID="Button6" class="t2" Text="撤销" CommandName="cancel" runat="server" CausesValidation="False"></asp:Button></p>
    </td>
    </tr>
    </EditItemTemplate>
    <FooterTemplate>
    <tr>
    <td width="97%" colSpan="8" height="26">
    <hr color="#c0c0c0" SIZE="1">
    </td>
    </tr>
    </table>
    </FooterTemplate> </asp:TemplateColumn> </Columns> </asp:datagrid>