How to use Regularexpressionvalidator in RadGrid control?

7 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
    2732 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. UI for ASP.NET Ajax is Ready for VS 2017
  4. 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
  5. 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.
  6. 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
  7. 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? 
  8. 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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017