<asp:TemplateField HeaderText="Quantity">
<ItemTemplate>
<asp:Label ID="lbl_quantity" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"quantity") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="txtquantity" Width="90px" onkeypress="return validatenumerics(event);" Text='<%# DataBinder.Eval(Container.DataItem,"quantity") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="RFquantity" runat="server" ControlToValidate="txtquntity" Display="None" ErrorMessage="This field is required value" ValidationGroup="quantity">
</asp:RequiredFieldValidator>
<ajaxToolkit:ValidatorCalloutExtender ID="VCquantity" runat="Server" TargetControlID="RFquantity"/>
</EditItemTemplate>
</asp:TemplateField>
我想显示一条 javascript 消息,如果文本框为空..我试过这段代码。出于验证目的,添加了所需的字段验证。然后“编辑”按钮不会被触发..请帮助我。
这是我的带有编辑、更新、取消和取消按钮的网格
protected void gvproducts_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
gvproducts.EditIndex = -1;
grid();
}
protected void gvproducts_RowEditing(object sender, GridViewEditEventArgs e)
{
gvproducts.EditIndex = e.NewEditIndex;
grid();
}
protected void gvproducts_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
TextBox txtquantity = (TextBox)gvproducts.Rows[e.RowIndex].Cells[4].Controls[1];
int st = Convert.ToInt32(gvproducts.DataKeys[e.RowIndex].Values[0].ToString());
objsupplyPL.quantity = Convert.ToInt32(txtquantity.Text.ToString());
objsupplyPL.sno = st;
DataTable scmpurchase = new DataTable();
scmpurchase = objsupplyBAL.updatepurchase(objsupplyPL);
ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "UpdateDetails", "alert('Update Successful');", true);
gvproducts.EditIndex = -1;
grid();
}