title: how to add validation in gridview textbox?
body: <pre><code>&lt;asp:TemplateField HeaderText="Quantity"&gt;
      &lt;ItemTemplate&gt;
          &lt;asp:Label ID="lbl_quantity" runat="server" Text='&lt;%# DataBinder.Eval(Container.DataItem,"quantity") %&gt;'&gt;
          &lt;/asp:Label&gt;
  
      &lt;/ItemTemplate&gt;
  
      &lt;EditItemTemplate&gt;
          &lt;asp:TextBox runat="server" ID="txtquantity" Width="90px" onkeypress="return validatenumerics(event);" Text='&lt;%# DataBinder.Eval(Container.DataItem,"quantity") %&gt;'&gt;&lt;/asp:TextBox&gt;
          &lt;asp:RequiredFieldValidator ID="RFquantity" runat="server" ControlToValidate="txtquntity" Display="None" ErrorMessage="This field is required value" ValidationGroup="quantity"&gt;
          &lt;/asp:RequiredFieldValidator&gt;
          &lt;ajaxToolkit:ValidatorCalloutExtender ID="VCquantity" runat="Server" TargetControlID="RFquantity"/&gt;
  
      &lt;/EditItemTemplate&gt;
  &lt;/asp:TemplateField&gt;
  </code></pre>
  
  <p>I want to shows an javascript message , if text box is empty..i tried this code. for validation purpose required field validation is added.then "edit" button is not fired..please help me.</p>
  
  <p>This is my grid with edit ,update ,cancel and cancel button</p>
  
  <pre><code>  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();
  }
  </code></pre>