Control Validation

2 posts, 1 answers
  1. Kyle Jones
    Kyle Jones avatar
    30 posts
    Member since:
    Jul 2009

    Posted 18 Aug 2009 Link to this post


    I am having problems with my control validation.  I am using the validation that you provided on this page: Validation.  My problem is that when my application calls my insert or update I am not able to grab the values inside my grid that have the validators attached to them.  When I remove the validation my code grabs the vaules properly.  Any help would be great.

    Here is the code that is grabbing data out of my grid:

    GridEditableItem editedItem = e.Item as GridEditableItem;
                GridEditManager editManager = editedItem.EditManager;

                int i = 0;
                foreach (Telerik.Web.UI.GridColumn column in e.Item.OwnerTableView.RenderColumns)
                    if (column is IGridEditableColumn)
                        IGridEditableColumn editableCol = (column as IGridEditableColumn);
                        if (editableCol.IsEditable)
                            IGridColumnEditor editor = editManager.GetColumnEditor(editableCol);

                            if (editor is GridDropDownColumnEditor)
                                CoverageUpdates[i] = (editor as GridDropDownColumnEditor).SelectedValue;
                            else if(editor is GridNumericColumnEditor)
                                CoverageUpdates[i] = (editor as GridNumericColumnEditor).Text;
                                CoverageUpdates[i] = (editor as GridTextColumnEditor).Text;

    Here is my validator code:

    if (e.Item is GridEditableItem && e.Item.IsInEditMode)
                    GridEditableItem item = e.Item as GridEditableItem;

                    GridNumericColumnEditor editor = (GridNumericColumnEditor)item.EditManager.GetColumnEditor("CoverageLimit");

                    TableCell cell = (TableCell)editor.NumericTextBox.Parent;

                    RequiredFieldValidator validator = new RequiredFieldValidator();
                    editor.NumericTextBox.ID = "clID";
                    validator.ControlToValidate = editor.NumericTextBox.ID;
                    validator.ErrorMessage = "Required";

                    GridNumericColumnEditor editor2 = (GridNumericColumnEditor)item.EditManager.GetColumnEditor("Deductible");

                    TableCell cell2 = (TableCell)editor2.NumericTextBox.Parent;

                    RequiredFieldValidator validator2 = new RequiredFieldValidator();
                    editor2.NumericTextBox.ID = "dId";
                    validator2.ControlToValidate = editor2.NumericTextBox.ID;
                    validator2.ErrorMessage = "Required";


    Kyle Jones
  2. Answer
    Iana Tsolova
    Iana Tsolova avatar
    3388 posts

    Posted 21 Aug 2009 Link to this post

    Hello Kyle,

    Could you please try removing the lines of your code where you set the NumericTextBox ID and see if it
    works thus:

    RequiredFieldValidator validator = new RequiredFieldValidator();  
    validator.ControlToValidate = editor.NumericTextBox.ID;  
    validator.ErrorMessage = "Required";  
    GridNumericColumnEditor editor2 = (GridNumericColumnEditor)item.EditManager.GetColumnEditor("Deductible");  
    TableCell cell2 = (TableCell)editor2.NumericTextBox.Parent;  
    RequiredFieldValidator validator2 = new RequiredFieldValidator();  
    validator2.ControlToValidate = editor2.NumericTextBox.ID;  
    validator2.ErrorMessage = "Required";  

    Let me know how it goes.

    Kind regards,
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. DevCraft R3 2016 release webinar banner
Back to Top