How to use Regularexpressionvalidator in RadGrid control?

9 posts, 0 answers
  1. Indranath
    Indranath avatar
    7 posts
    Member since:
    May 2011

    Posted 02 Jun 2011 Link to this post

    Hi Guys,

    How can I use regularexpressionvalidator in RadGrid control with <InsertTemplate> and <EditTemplate>. Is there any other alternative for this.

    In case of regEx fail, I am able to display the '*' next to the control but not the message in ValidationSummary [rendering as display:none].

    Thanks in advance.

    -regards
    Indra
  2. Jayesh Goyani
    Jayesh Goyani avatar
    2733 posts
    Member since:
    May 2010

    Posted 02 Jun 2011 Link to this post

    Hi,

    plz refer below link and let me know if any concern

    http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/templateformupdate/defaultcs.aspx

    Thanks,
    Jayesh Goyani
  3. Indranath
    Indranath avatar
    7 posts
    Member since:
    May 2011

    Posted 02 Jun 2011 Link to this post

    I don't see validationsummary control used in this example.

    Thanks
    Indra
  4. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 03 Jun 2011 Link to this post

    Hello Indranath,

    The following demo explains the flexible server-side validation mechanism of the RadGrid edit form. Check whether it helps you.

    Grid / Flexible Server-side Validation.

    Thanks,
    Princy.
  5. Indranath
    Indranath avatar
    7 posts
    Member since:
    May 2011

    Posted 03 Jun 2011 Link to this post

    Princy thanks for your response, I am looking something client side validation using regularexpression.

    -regards
    Indra
  6. Peter
    Peter avatar
    98 posts
    Member since:
    Mar 2012

    Posted 07 Jul 2014 in reply to Indranath Link to this post

    I too would like to know how to use a RegularExpressionValidator control on a GridBoundColumn ... is it possible? 
  7. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 07 Jul 2014 in reply to Peter Link to this post

    Hi Peter,

    Please try the following code snippet to have a RegularExpressionValidator for a GridBoundColumn.

    C#:
    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    {
      if (e.Item is GridEditableItem && e.Item.IsInEditMode)
      {
       GridEditableItem item = e.Item as GridEditableItem;
       GridTextBoxColumnEditor editor = (GridTextBoxColumnEditor)item.EditManager.GetColumnEditor("ColumnUniqueName");
       TableCell cell = (TableCell)editor.TextBoxControl.Parent;
       RegularExpressionValidator validate = new RegularExpressionValidator();
       validate.ControlToValidate = editor.TextBoxControl.ID;
       validate.ValidationExpression = "Expression";
       validate.ErrorMessage = "Error Message";
       cell.Controls.Add(validate);
      }
    }

    Thanks,
    Princy
  8. Matt
    Matt avatar
    50 posts
    Member since:
    Jun 2012

    Posted 12 hours ago in reply to Princy Link to this post

    I know it's been a couple of years but in bulk edit mode, this event is not being raised.
  9. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3908 posts

    Posted 11 hours ago Link to this post

    Hi Matt,

    The following article shows how to use a custom validator in batch edit mode: https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/data-editing/edit-mode/batch-editing/validation.

    If using that approach + the latest version does not help, I advise that you open a ticket and send us a small mockup that shows the issue.

    Regards,

    Marin Bratanov
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top