我有gridview,我想在其中验证我的两列。
在第一栏中说将有150Kg的数量, 那么用户不应该能够增加超过150的值,因为它更大并且不应该接受它。
请建议如何在javascript中执行此操作。
<cc1:Grid ID="GrdConfirmation" EnableTypeValidation="true" runat="server" Width="100%"
ShowFooter="false" AllowAddingRecords="true" AllowSorting="false" AutoGenerateColumns="false"
FolderStyle="../Styles/Grid/style_12">
<ClientSideEvents OnClientSelect="GrdConfirmation_OnClientSelect" />
<Columns>
<cc1:Column ID="Column1" DataField="MKEY" HeaderText="Select" ReadOnly="true" Width="3%"
runat="server">
<TemplateSettings TemplateId="gtchkConfirm" HeaderTemplateId="HTConfirm" />
</cc1:Column>
<cc1:Column ID="Sr_No" DataField="Sr_No" HeaderText="Sr No" Visible="false" Width="0%">
<TemplateSettings TemplateId="tplNumbering" />
</cc1:Column>
<cc1:Column ID="col_save_srno" DataField="save_srno" HeaderText="Sr.No" Visible="true"
Width="3%" Align="center">
</cc1:Column>
<cc1:Column ID="Line_Id" DataField="Line_Id" HeaderText="Line id" Visible="false"
Align="left" Width="0%">
</cc1:Column>
<cc1:Column ID="Item_Mkey" DataField="Item_Mkey" HeaderText="Item Mkey" Visible="false"
Align="center" Width="0%">
</cc1:Column>
<cc1:Column ID="Item_Code" DataField="Item_Code" HeaderText="Item Code" Visible="true"
Align="left" Width="6%">
</cc1:Column>
<cc1:Column ID="Item_Desc" DataField="Item_Desc" HeaderText="Item Description" Visible="true"
Align="left" Width="13%" Wrap="true" HeaderStyle-Wrap="true">
</cc1:Column>
<cc1:Column ID="Lot_Batch_No" DataField="Lot_Batch_No" HeaderText="Lot / Batch No."
Visible="true" Align="left" Width="7%" Wrap="true">
</cc1:Column>
<cc1:Column ID="Exp_Dt" DataField="Exp_Dt" HeaderText="Exp Date" Visible="true" Align="left"
Width="7%" Wrap="true">
</cc1:Column>
<cc1:Column ID="Qty" DataField="Qty" HeaderText=" Quantity" Visible="true" Width="6%"
Align="left">
</cc1:Column>
<cc1:Column ID="Bx_Bg" DataField="Bx_Bg" HeaderText="Boxes/Bags" Visible="true" Width="6%"
Align="left" HeaderAlign="left">
</cc1:Column>
<cc1:Column ID="Net_Wgt" DataField="Net_Wgt" HeaderText="Net Weight" Visible="true"
HeaderAlign="center" Width="7%" Align="center">
</cc1:Column>
<cc1:Column ID="NO_OF_PALLETS" DataField="NO_OF_PALLETS" HeaderText="No Of Pallets"
HeaderAlign="center" Visible="true" Align="center" Width="6%" Wrap="true">
</cc1:Column>
<cc1:Column ID="Default_Allot" DataField="Default_Allot" HeaderText="Allocated Storage Bin No."
Visible="true" Width="10%" Align="center" Wrap="true">
</cc1:Column>
<cc1:Column ID="Confirmed_Allot" DataField="Confirmed_Allot" HeaderText="Confirmed Storage Bin No."
Visible="true" Width="10%" Align="center" Wrap="true">
<TemplateSettings TemplateId="PlainEditTemplate" />
</cc1:Column>
<cc1:Column ID="Storage_type" DataField="Storage_type" HeaderText="Storage Type"
Visible="false" Width="0%" Align="center" Wrap="true">
</cc1:Column>
<cc1:Column ID="Damaged_Qty" DataField="Damaged_Qty" HeaderText="Damaged Qty in Units"
Visible="true" Width="5%" Align="center" Wrap="true">
<TemplateSettings TemplateId="PlainEditTemplate" />
</cc1:Column>
<cc1:Column ID="Short_Fall_Excess" DataField="Short_Fall_Excess" HeaderText="Shortfall/ excess qty in units"
Visible="true" Width="5%" Align="center" Wrap="true">
<TemplateSettings TemplateId="PlainEditTemplate" />
</cc1:Column>
</Columns>
<Templates>
<cc1:GridTemplate runat="server" ID="PlainEditTemplate">
<Template>
<asp:TextBox runat="server" ID="txtconfirm" CssClass="excel-textbox" onfocus="markAsFocused(this)"
onblur="markAsBlured(this)" />
</Template>
</cc1:GridTemplate>
</Templates>
<AddEditDeleteSettings AddLinksPosition="Bottom" NewRecordPosition="Dynamic" />
<Templates>
<cc1:GridTemplate runat="server" ID="GridTemplate1">
<Template>
<input id="txttemp" type="text" />
</Template>
</cc1:GridTemplate>
</Templates>
<Templates>
<cc1:GridTemplate runat="server" ID="HTConfirm">
<Template>
<input type="checkbox" onclick="toggleSelection(this)" id="ChkSelector" />
</Template>
</cc1:GridTemplate>
<cc1:GridTemplate runat="server" ID="gtchkConfirm">
<Template>
<asp:CheckBox ID="chk_grid" runat="server" />
</Template>
</cc1:GridTemplate>
</Templates>
<Templates>
<cc1:GridTemplate runat="server" ID="TextBoxEditTemplate">
<Template>
<input type="text" name="TextBox1111" id="Txtconfirm<%# (Container.RecordIndex) %>"
class="excel-textbox" readonly="readonly" onfocus="GrdConfirmation.editWithTextBox(this)" />
</Template>
</cc1:GridTemplate>
<cc1:GridTemplate runat="server" ID="tplNumbering">
<Template>
<b>
<%# (Container.RecordIndex + 1)%>
</b>
</Template>
</cc1:GridTemplate>
<cc1:GridTemplate ID="TemplateWithCheckbox">
<Template>
<asp:CheckBox runat="server" ID="ChkID" ToolTip="<%# Container.Value %>" />
</Template>
</cc1:GridTemplate>
</Templates>
</cc1:Grid>
我的两栏是
<cc1:Column ID="Bx_Bg" DataField="Bx_Bg" HeaderText="Boxes/Bags" Visible="true" Width="6%"
Align="center">
</cc1:Column><cc1:Column ID="Damaged_Qty" DataField="Damaged_Qty" HeaderText="Damaged Qty in Units"
Visible="true" Width="5%" Align="center" Wrap="true">
<TemplateSettings TemplateId="PlainEditTemplate" />
</cc1:Column>
我希望用GrdConfirmation_OnClientSelect()
函数
答案 0 :(得分:1)
假设您只想在客户端验证并且您的要求不是专门在javascript中手动处理此问题,您可以通过添加以下模板来执行此操作:
<cc1:GridTemplate runat="server" ID="WeightTemplate">
<Template>
<asp:TextBox runat="server" ID="txtWeight" CssClass="excel-textbox" onfocus="markAsFocused(this)" onblur="markAsBlured(this)" />
<asp:RangeValidator ID="WeightValidation" runat="server" ErrorMessage="Invalid weight" ValidationGroup="Validation" Type="Integer" ControlToValidate="txtWeight" MinimumValue="0" MaximumValue='<%# Eval("MaxWeight") %>' EnableClientScript="true"></asp:RangeValidator>
</Template>
</cc1:GridTemplate>